Search Postgresql Archives

Re: problem with serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am CCing list so more eyes can see this and because I don't use PHP.

On 04/19/2012 07:59 AM, Yvon Thoraval wrote:




    What does the error say?

Fatal error: Call to a member function fetch() on a non-object in
/home/yt/Sites/landp_public/landp.php on line 500

This is PHP/PDO error message, here is my code :
$max_rowid=-1;
$sql="SELECT MAX(rowid) FROM items;";
$ret=$db->query($sql);
while($row=$ret->fetch()){
$max_rowid=$row['max'];
}
$last_value=-1;
$sql="SELECT last_value FROM items_rowid_seq;";
$ret=$db->query($sql);
while($row=$ret->fetch()){
$last_value=$row['last_value'];
}
if($last_value<$max_rowid){
$sql="SELECT setval('items_rowid_seq', max(rowid)) FROM items;";
$ret=$db->query($sql);
while($row=$ret->fetch()){
$last_value=$row['setval'];
}
if($last_value<$max_rowid){
// générer une erreur
}
}
$rowid=-1;
$sql="INSERT INTO items (ctime, [...], infos) VALUES (
'".$dat."', [...], '".str2sql(quoteAsAre($_GET["infos"]))."') RETURNING
rowid;";
$ret=$db->query($sql);
while($row=$ret->fetch()){ // LINE 500
$rowid=$row['rowid'];
}

  if i test it, $ret isn't an object.

may be this has nothing to do with psql but rather with PHP/PDO.

It might even be a typo ?

But this works "sometime" ???



--
Yvon




--
Adrian Klaver
adrian.klaver@xxxxxxxxx

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux