Tuesday, August 2, 2011

Re: mysql_insert_id() as virtual model field

ah, some other part of the system is making the save()?
I mean, there needs to be a save to get the last insert ID?


and.. is this helpful?
public $virtualFields = array('insert_id' => 'last_insert_id()');


I think there are some problems listed on the 'net about mysql client
connections holding their own value for the last insert ID too that you
may need to be wary of.


On 02/08/11 21:16, Johkke wrote:
> The problem is, I'm not saving any data. I'm just pulling it out of
> the database.
>
> On 1 aug, 13:01, Douglas Reith<doug...@reith.com.au> wrote:
>> I'm sorry if I've mistook your question, but after you've done a save
>> with Cake you can just use
>> Model->id
>> will that work?
>>
>> e.g. from the book:
>>
>> 1. |$this->Ingredient->save($newData);|
>> 2. |$newIngredientId = $this->Ingredient->id;|
>>
>> On 30/07/11 18:53, Johkke wrote:
>>
>>
>>
>>> Is it possible to have the mysql_insert_id as virtual field of an
>>> model?
>>> I'm implementing an ticket system interface and ticket numbers given
>>> by the mysql_insert_id

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: