Hmmm... Conceptually, that'd be OK for the first time, but not
exactly what I would be looking for when I used the same $this->Foo-
>field('id', $cond); call for existing records that may have been
updated. How would I save the output of getLastInsertId() to the 'id'
value of the current instance of Foo so that $this->Foo->field('id',
$cond); would return it properly (called from a different method)?
On Aug 31, 4:06 pm, "John David Anderson (_psychic_)"
<[EMAIL PROTECTED]> wrote:
> On Aug 31, 2007, at 1:24 PM, [EMAIL PROTECTED] wrote:
>
>
>
> > I'm working on a CakePHP script running from the command-line. I'm
> > attempting to check for a record in table "foo", and if it doesn't
> > exist, I add a new record using the Model::save() method. Afterwards,
> > I immediately call Model::field() to try to capture the
> > auto_incremented "id" field so that I can do extra work relating to
> > that record.
>
> > Problem is, when I call $this->controller->Foo->field( 'id',
> > $conditions ); immediately after the save, it returns null. In fact,
> > this happens every time for that record until the script has completed
> > and is run a second time.
>
> Have you tried using getLastInsertId() rather than field()?
>
> -- John
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---