SOLVED Re: DB::nextId w/ Postgres 7.4
| From: | Jackson Miller | Date: | Wed, 17 Dec 2003 16:08:57 +0000 |
| Subject: | SOLVED Re: DB::nextId w/ Postgres 7.4 | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9620@lists.php.net to get a copy of this message | ||
This email is mostly just for the archives.
On Tuesday 16 December 2003 23:39, Jackson Miller wrote:
> I am having a problem using nextId with PostgreSQL 7.4. When I try to get
> the next value in an existing sequence it returns an error object with no
> message or error code.
I figured this out thanks to a friend who had run into this before.
If you name your sequence in PostgreSQL something like "my_table_seq", where
"my_table" is the table that uses the sequence as it's primary key, then you
must actually run nextId like this:
$db->nextId('my_table');
In hindsight I understand why this is so (it makes it easier for the same code
to work with multiple database types). However, an error code would be
great.
-Jackson
>
> I have used get_class_vars() and get_class_methods().
>
> It has no properties (vars) and is definitely an error object (has
> getMessage() method).
>
> Further when I run the following query directly in postgres it works fine.
>
> SELECT nextval('my_sequence'::text);
>
>
> This is the php code that consistently fails.
>
> $db->nextId('my_sequence');
>
> I can run selects off this DB instance without a problem.
>
> Is there something different about PostgreSQL 7.4? am I doing something
> wrong?
>
> -Jackson