You guys thought of everything. That's pretty sweet.

On Sun, Feb 24, 2008 at 5:36 PM, nate <[EMAIL PROTECTED]> wrote:
>
>  Some older versions of Postgres won't tell you the sequence name for a
>  column (I think the earliest version I've tested on is 8.1 or so).  In
>  those cases, you need to do as Chris says, and provide the sequence
>  name in the model class using var $sequence.
>
>
>  On Feb 23, 12:12 pm, "b logica" <[EMAIL PROTECTED]> wrote:
>  > What is the model name you're dealing with here? The 'public' part of
>  > the query refers to the public schema and is used in creating the
>  > sequence name (from which the last value is to be gotten). It looks
>  > like something in your table name is causing Cake to come up with an
>  > incomplete sequence name:
>  >
>  > function lastInsertId($source, $field = 'id') {
>  >         foreach ($this->__descriptions[$source] as $name => $sourceinfo) {
>  >                 if (strcasecmp($name, $field) == 0) {
>  >                         break;
>  >                 }
>  >         }
>  >
>  >         if (isset($this->_sequenceMap[$source])) {
>  >                 $seq = $this->_sequenceMap[$source];
>  >         } elseif (preg_match('/^nextval\(\'(\w+)\'/', 
> $sourceinfo['default'],
>  > $matches)) {
>  >                 $seq = $matches[1];
>  >         } else {
>  >                 $seq = "{$source}_{$field}_seq";
>  >         }
>  >
>  >         $res = $this->rawQuery("SELECT last_value AS max FROM \"{$seq}\"");
>  >         $data = $this->fetchRow($res);
>  >         return $data[0]['max'];
>  >
>  > }
>  >
>  > If you can, log into psql and type:
>  >
>  > \ds
>  >
>  > to see your sequence names. Maybe something's screwy there. Otherwise,
>  > it might be something you've set in your Cake app.
>  >
>
>
> > On Sat, Feb 23, 2008 at 1:27 AM, Bruce <[EMAIL PROTECTED]> wrote:
>  >
>  > >  I am working in Cake 1.2 with PHP5 and a postgres backend DB. When I
>  > >  try to create records in any app I have tried, I get a warning then an
>  > >  SQL error. The record seems to be created in the db, but with my
>  > >  limited knowledge, it looks to me like cake is constructing an
>  > >  incomplete SQL statement when trying to retrieve the ID of the record
>  > >  just written.
>  >
>  > >  Output is like:
>  >
>  > >  Warning (2): pg_query() [function.pg-query]: Query failed: ERROR:
>  > >  relation "public" does not exist [CORE/cake/libs/model/datasources/dbo/
>  > >  dbo_postgres.php, line 122]
>  >
>  > >  Code | Context
>  > >  $sql    =       "SELECT last_value AS max FROM "public""
>  > >   */
>  > >     function _execute($sql) {
>  > >         return pg_query($this->connection, $sql);
>  >
>  > >  pg_query - CORE/cake/libs/model/datasources/dbo/dbo_postgres.php, line
>  > >  122
>  > >  DboPostgres::_execute() - CORE/cake/libs/model/datasources/dbo/
>  > >  dbo_postgres.php, line 122
>  > >  DboPostgres::execute() - CORE/cake/libs/model/datasources/
>  > >  dbo_source.php, line 155
>  > >  DboPostgres::fetchRow() - CORE/cake/libs/model/datasources/
>  > >  dbo_source.php, line 269
>  > >  DboPostgres::lastInsertId() - CORE/cake/libs/model/datasources/dbo/
>  > >  dbo_postgres.php, line 355
>  > >  DboPostgres::create() - CORE/cake/libs/model/datasources/
>  > >  dbo_source.php, line 500
>  > >  JobHistory::save() - CORE/cake/libs/model/model.php, line 1234
>  > >  JobHistoriesController::add() - APP/controllers/
>  > >  job_histories_controller.php, line 23
>  > >  Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 265
>  > >  Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 237
>  > >  [main] - APP/webroot/index.php, line 84
>  > >  Query: SELECT last_value AS max FROM "public"
>  >
>  > >  Any suggestions?
>  >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to