开发者

Zend and oracle sequence

开发者 https://www.devze.com 2023-02-15 04:35 出处:网络
I\'m trying to insert a new statement to Oracle. My aim is to create clean sql query. I have a table containing ID, username, password.

I'm trying to insert a new statement to Oracle. My aim is to create clean sql query.

I have a table containing ID, username, password. I have following code

$sql = 'insert INTO EMPLOYEES (ID, LOGIN, PASSWORD) VALUES (:seq,  :login, :pass)';
$stmt = new Zend_Db_Statement_Pdo_Oci(Zend_Registry::get('db'), $sql);
$stmt->execute(array(':seq' => new Zend_Db_Expr('RK.EMP_SEQUENCE.NEXTVAL'),':login' => 'sss', ':pass' => 's'));

(registry stores oci_pdo adapter)

but it gives me:

Message: SQLSTATE[HY000]: General error: 1722 OCIStmtExecute: ORA-01722: invalid number (ext\pdo_oci\oci_statement.c:146)

I can't figure out what happens, because there is literally no info 开发者_开发知识库in google=( Any advice?


How about just do this:

$sql = 'insert INTO EMPLOYEES (ID, LOGIN, PASSWORD) VALUES (RK.EMP_SEQUENCE.NEXTVAL,  :login, :pass)';

Now just bind the login and password and execute.


You can inform Zend what is the name of your sequence:

<?php
class A extends Zend_Db_Table_Abstract
{
    protected $_sequence = 'RK.EMP_SEQUENCE';
    ....
0

精彩评论

暂无评论...
验证码 换一张
取 消