Reply to Re: PDO Gnashing of teeth and pulling of hair.

Your name:

Reply:


Posted by Erwin Moller on 10/03/05 13:26

smorrey@gmail.com wrote:

> Assuming this...
> $_SESSION['db'] = new PDO(
> "pgsql:dbname=test;host=localhost",
> "biocoinadmin",
> "xxxxxxxxxx"
> );
>
>
> What is wrong with this (line breaks added for clarity)?
>
> $sql = "SELECT * FROM public.authinfo WHERE uid = '$uid'";
> if ($_SESSION['db']->fetchAll(
> $_SESSION['db']->query($sql)) > 0
> ){
> dosomething();
> }else{
> dosomethingelse();
> }
>
> I keep getting this error...
>
> Fatal error: Call to undefined method PDO::fetchAll() in
> /home/testcode/public_html/header.php on line 114
>
> This doesn't make sense, because every other query I issue on the DB
> seems to be working great. This is the first time anykind of fetch is
> used, and it should just let me know if there is any data at all, as a
> result of the query right? I'm not asking for anything specific just a
> yes or no as to whether that uid exists in the DB.
>
> Any advice here?

Hi,

I think your handle to the database breaks when the session is serialized
and saved between pages. The unserialized connection you use on the next
page is not a valid connection anymore. (This is no Java)

Solution: Do not store a databaseconnection in a session: Recreate it on
every page.

If you still worry about speed: Have a look at pg_pconnect().
It uses a permanent connection.

My experience with Postgres and starting a fresh databaseconnection are very
good. It is superfast. I never used pg_pconnect.

Regards,
Erwin Moller

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация