2008年8月4日星期一

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

ok, i see what you are saying. What about if i receive an array of info and
want to update/insert it?

Would/could I run fetchRow and be returned an empty object, use the info
submitted from a form and then save() it? Would it then be able to check if
row exisits and if not, insert it?

Thanks.


... what does ITOH mean?

thanks.

Xavier Vidal Piera wrote:
>
> 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
>
>

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

没有评论: