On 6/14/07, Bill Karwin <[EMAIL PROTECTED]> wrote:
Probably you should use the $db->lastSequenceId($sequenceName) method.
See
http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.write.lastinsertid
Regards,
Bill Karwin
------------------------------
*From:* Svetlin Petrov [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, June 14, 2007 3:17 AM
*To:* [email protected]
*Subject:* [fw-general] Zend_DB Oracle adapter
Hi,
I need to execute query like this one:
INSERT INTO deal
> (name, deal_type)
> VALUES
> (:name, :deal_type)
> RETURNING
> id
> INTO
> :id
>
If I do not use Zend Framework, I do the following:
$stmt = oci_parse($_conn, $sql);
>
>
> oci_bind_by_name($stmt, ":name", $name, 32);
> oci_bind_by_name($stmt, ":deal_type", $deal_type, 32);
> oci_bind_by_name($stmt, ":id", $id, -1, SQLT_INT);
>
> oci_execute($stmt);
My question is: is there an way to do this inside Zend Framework?
Thanks!
Svetlin Tsvetanov
--
http://www.spetrov.com
I found a way to solve the issue:
$sql = 'INSERT INTO deal
(name, deal_type)
VALUES
(:name, :deal_type)
RETURNING
id
INTO
:id';
$stmt = $zendDB->prepare($sql);
$stmt->bindParam(':name', $name, null, 32);
$stmt->bindParam(':deal_type', $deal_type, null, 32);
$stmt->bindParam(':id', $id, SQLT_INT, -1);
$stmt->execute();
And in $id I have the last inserted ID.
It works perfectly.
Regards,
Svetlin Tsvetanov
--
http://www.spetrov.com