On 8/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Well, the query definitely runs, as the data exists in the table after
> the script completes. The problem is that I'm trying to access the
> new row in the table during the same run of the script immediately
> after running Model::save(), under the assumption that this command
> would immediately save the result in the database. Maybe it's just
> that the model itself is caching the data and I need a better way of
> forcing a read?
>
There is no "caching of data" when it saves, and there is no command
to "force reads". Whenever I've wanted the id of a record I've just
saved, I've done the following:
// assume $this->data has stuff in it
if ($this->Foo->save($this->data)) {
$fooId = $this->Foo->getLastInsertId();
}
Then you go on your merry way doing whatever other work you wanted to
do, happy in the knowledge that $fooId contains the id of the record
you just created in the table associated with the Foo model.
Hope that helps.
--
Chris Hartjes
Senior Developer
Cake Development Corporation
My motto for 2007: "Just build it, damnit!"
@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---