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?
On Aug 31, 4:08 pm, Matt <[EMAIL PROTECTED]> wrote: > I find if you are saving a model it is always best to use save($this- > > >data->model); > > In my experience if you don't do this then you don't always save the > model. > > Have you tried using exit() right after the save, then checking your > table manualy to ensure the query ran? > > On Aug 31, 12:24 pm, "[EMAIL PROTECTED]" <[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. > > > I'm used to running scripts in Perl or TCL where when you make a > > database call, it completes immediately, so I'm confused by what seems > > to be some kind of caching of the data here. I can't seem to find any > > kind of flush() method to complete allow all of these things to be > > refreshed. Obviously I'm VERY new to CakePHP. Any insight here would > > be greatly appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
