2008年9月8日星期一

Re: [fw-db] Zend DB Table and Oracle

mikaelkael wrote:
>
> You must have a sequence on Oracle if you want retrieve a "SOFTWARE_ID"
> like an auto_increment field of MySQL.
> My remember is that sequence must be name: $_tableName . '_SEQ'
>

You don't need to name the Oracle sequence by any convention.

You do need to specify the name of the sequence in your Table class
definition, e.g.:

class Software extends Zend_Db_Table_Abstract
{
protected $_sequence = 'software_id_seq';
}

That's just an example. Replace 'software_id_seq' with the name of the
sequence you define in the database to populate the software_id column.

If you don't specify the $_sequence attribute to the name of the sequence,
Zend_Db_Table's default behavior is more like MySQL's AUTO_INCREMENT
functionality. It assumes it can fetch the last generated id value after
the insert.

But if you use Oracle and you specify the sequence name as a string as shown
above, Zend_Db_Table fetches a new id value from the sequence _before_ the
insert.

Regardless of whether you use MySQL or Oracle, after you call $row->save()
the primary key column in this row should be populated with the generated
value.

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Zend-DB-Table-and-Oracle-tp19380170p19381404.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: