2008年8月4日星期一

Re: [fw-db] Zend_Db_Table / Row / Rowset

Zend_Db_Table_Row behaves that way already. If you load the row from db it will have a primary key field filled inside, so if you save it later this object will update that data.

ITOH, if you create a row with "$table->createRow()", the primary key fields will be null and a later "save" will do an insert.

So, if you look at the internals of Zend_Db_Table_Row you will see two arrays: the first one is for storing the fresh data and the other one holds the 'dirty data', so comparing both you can know which fields have changed and if the primary keys fields are filled up.

Hope it helps.

On Mon, Aug 4, 2008 at 21:16, maxarbos <maxarbos@yahoo.com> wrote:

Hello,

I  am looking through the docs and see the save() method associated with
Zend_Db_Table_Row and Rowset, is there a method that will check for a primry
key val of XX and update it, otherwise insert it, automatically?

I want to be able to update a row in a table that may or may not be in the
table.
i would like to be able to just set my array to contain the record id i want
to update and execute save().
If that ID doesnt exisit, then insert instead of update.


--
View this message in context: http://www.nabble.com/Zend_Db_Table---Row---Rowset-tp18817752p18817752.html
Sent from the Zend DB mailing list archive at Nabble.com.




--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
xavividal@gmail.com
xvidal@lavanguardia.es
http://web.xaviervidal.net
610.68.41.78

没有评论: