I have see your question and if you want test my example to solve your
problem:
-----------------------
$db = Database::NewConnection();
$db->setFetchMode(Zend_Db::FETCH_OBJ);
$id = 6;
$db->query('SET @bob = 0');
$stmt = $db->query('SELECT @bob:=@bob+1 AS bob, FIRST, SECOND FROM
table_Name WHERE FIRST = ?',array($id));
$rows = $stmt->fetchAll();
------------------------
janpolsen wrote:
>
> Is it possible to run multiple SQL queries either at the same time or one
> after another?
>
> Let's say I want to make the following:
> DECLARE @bob INT;
> SET @bob = 42;
> SELECT @bob AS bob;
>
> So I go for:
> $sql = "DECLARE @bob INT;SET @bob = 42; SELECT @bob AS bob;";
> var_dump($db->fetch*($sql));
> None of the fecth*()-methods gives me a result of 42.
>
> If I try with:
> $sql1 = "DECLARE @bob INT;";
> $sql2 = "SET @bob = 42;";
> $sql3 = "SELECT @bob AS bob;";
> $db->query($sql1);
> $db->query($sql2);
> $db->query($sql3);
>
> The I get an error at the second query() telling me that @bob is unknown.
>
--
View this message in context: http://www.nabble.com/Multiple-SQL-queries-tp20717372p24360208.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论