Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-23-2008, 10:42 PM
Dead_Thinker's Avatar
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-28-2008, 01:04 PM
Dead_Thinker's Avatar
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
Default

Hi, about this issue, i realize than the problem is a trigger on tables what are making the IDs to 'jump' one number, and if i set the Sequence Name is enough for retrive the ID on a insert operation

If someone has the same problem...that's my experience...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:10 AM.