Zend and oracle sequence
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';
....
精彩评论