View Single Post
  #1 (permalink)  
Old 02-23-2008, 10:42 PM
Dead_Thinker's Avatar
Dead_Thinker Dead_Thinker is offline
Junior Member
 
Join Date: May 2007
Location: Fortaleza/Ceará/Brazil
Posts: 20
Send a message via ICQ to Dead_Thinker Send a message via Yahoo to Dead_Thinker Send a message via Skype™ to Dead_Thinker
Question [Oracle] Always mode code lines to get last ID?

Hi,

i'm testing the use of Zend Framework with Oracle and for what can i see, to get the inserted id i have to use one of the codes below:
PHP Code:
$oModel->getAdapter()->lastInsertId('TABLENAME');
// Or
$oModel->getAdapter()->lastSequenceId('SEQUENCENAME'); 
The code below, with Oracle adapter, don't return the ID, just NULL:
PHP Code:
$id $oModel->insert(array('FIELDNAME' => 'my data')); 
But, if in the model configurations i put the $_sequence like below:
PHP Code:
class MyModel extends Zend_Db_Table {
    protected 
$_name    'TABLENAME';
    protected 
$_primary    = array('COLLUM_PK');
    public 
$_sequence    'SEQUENCE_NAME';

The insert method insert the ID 45 for example, but the last is the 43, one is skipped, but the insert method return to me 44, and the lastInsertId and lastSequenceId methods keep returning the correct ID.

Is this correct?
I always will have to use the lastInsertId and lastSequenceId methods to get the last ID? Can't just use the insert method return like i'd use in others adapters like PDO_MSSQL?

Thanks!
Reply With Quote