I wish to use PostgreSQL with PHP+PDO. I haven't use PDO before.
I have the php-pdo package installed on my CentOS 4.7 server:
# rpm -qa |grep pdo php-pdo-5.1.6-3.el4s1.10
Now when I try connect to the PostgeSQL db with this code:
<?php print "PDO test<br />"; try { $db = new PDO("pgsql:host=192.168.0.180;port=5432;dbname=mydb;user=test;password=test");
} catch(PDOException $e) { print "Error : " . $e->getMessage() . "<br/>"; die(); } ?>
I get no output in the browser, but I see this error in Apache log:
PHP Fatal error: Class 'PDO' not found in /var/www/html/pdotest.php on line 4
Well, it appears the PDO class is not provided by the php-pdo package:
# rpm -ql php-pdo |less/etc/php.d/pdo.ini /etc/php.d/pdo_sqlite.ini /usr/lib/php/modules/pdo.so /usr/lib/php/modules/pdo_sqlite.so
So, what package does provide it or have I misunderstood something?
Regards, Peter
Peter Peltonen wrote:
I wish to use PostgreSQL with PHP+PDO. I haven't use PDO before.
I have the php-pdo package installed on my CentOS 4.7 server:
# rpm -qa |grep pdo php-pdo-5.1.6-3.el4s1.10
Now when I try connect to the PostgeSQL db with this code:
<?php print "PDO test<br />"; try { $db = new PDO("pgsql:host=192.168.0.180;port=5432;dbname=mydb;user=test;password=test"); } catch(PDOException $e) { print "Error : " . $e->getMessage() . "<br/>"; die(); } ?>
I get no output in the browser, but I see this error in Apache log:
PHP Fatal error: Class 'PDO' not found in /var/www/html/pdotest.php on line 4
Well, it appears the PDO class is not provided by the php-pdo package:
# rpm -ql php-pdo |less/etc/php.d/pdo.ini /etc/php.d/pdo_sqlite.ini /usr/lib/php/modules/pdo.so /usr/lib/php/modules/pdo_sqlite.so
So, what package does provide it or have I misunderstood something?
Regards, Peter _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Did you restart Apache after installing the php-pdo package? -Alan
On Wed, Aug 5, 2009 at 7:18 AM, Alan Sparksasparks@doublesparks.net wrote:
Peter Peltonen wrote:
I wish to use PostgreSQL with PHP+PDO. I haven't use PDO before.
I have the php-pdo package installed on my CentOS 4.7 server:
# rpm -qa |grep pdo php-pdo-5.1.6-3.el4s1.10
Now when I try connect to the PostgeSQL db with this code:
<?php print "PDO test<br />"; try { $db = new PDO("pgsql:host=192.168.0.180;port=5432;dbname=mydb;user=test;password=test"); } catch(PDOException $e) { print "Error : " . $e->getMessage() . "<br/>"; die(); } ?>
I get no output in the browser, but I see this error in Apache log:
PHP Fatal error: Class 'PDO' not found in /var/www/html/pdotest.php on line 4
Well, it appears the PDO class is not provided by the php-pdo package:
# rpm -ql php-pdo |less/etc/php.d/pdo.ini /etc/php.d/pdo_sqlite.ini /usr/lib/php/modules/pdo.so /usr/lib/php/modules/pdo_sqlite.so
So, what package does provide it or have I misunderstood something?
Regards, Peter _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Did you restart Apache after installing the php-pdo package? -Alan
Yes I did. I also have the package php-pgsql-5.1.6-3.el4s1.10 installed, which provides the following files:
# rpm -ql php-pgsql /etc/php.d/pdo_pgsql.ini /etc/php.d/pgsql.ini /usr/lib/php/modules/pdo_pgsql.so /usr/lib/php/modules/pgsql.so
And it should be enabled:
# more /etc/php.d/pdo_pgsql.ini ; Enable pdo_pgsql extension module extension=pdo_pgsql.so
Reading the php.net manual I get the impression that just loading these shared libraries should give me the PDO object to play with, right?
phpinfo() reports me:
Configure Command [...] '--disable-pdo'
additional .ini files parsed /etc/php.d/gd.ini, /etc/php.d/ldap.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_pgsql.ini, /etc/php.d/pdo_sqlite.ini, /etc/php.d/pgsql.ini
As the .ini files have been parsed, PDO should be in use, right? Otherwise PostgreSQL and MySQL work from PHP ok.
Regards, Peter
From: Peter Peltonen peter.peltonen@gmail.com
# more /etc/php.d/pdo_pgsql.ini ; Enable pdo_pgsql extension module extension=pdo_pgsql.so
Enabled it in /etc/php.d/pdo.ini ?
JD
Hi,
On Wed, Aug 5, 2009 at 11:46 AM, John Doejdmls@yahoo.com wrote:
From: Peter Peltonen peter.peltonen@gmail.com
# more /etc/php.d/pdo_pgsql.ini ; Enable pdo_pgsql extension module extension=pdo_pgsql.so
Enabled it in /etc/php.d/pdo.ini ?
Yes:
# more /etc/php.d/pdo.ini ; Enable pdo extension module extension=pdo.so
Peter
From: Peter Peltonen peter.peltonen@gmail.com
Enabled it in /etc/php.d/pdo.ini ?
Yes:
# more /etc/php.d/pdo.ini ; Enable pdo extension module extension=pdo.so
You said you saw "--disable-pdo"from configure...? Maybe that's the problem... standard php package? While I use PDO for sqlite, here's what I have:
$ php -i | grep -i pdo Configure Command => './configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--enable-dom=shared' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--enable-dbase=shared' /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini PDO PDO support => enabled PDO drivers => mysql, sqlite pdo_mysql PDO Driver for MySQL, client library version => 5.0.45 pdo_sqlite PDO Driver for SQLite 3.x => enabled PECL Module version => 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6 2006/01/01 12:50:12 sniper Exp $
I don't have the "--disable-pdo"
JD
On 08/04/2009 10:13 PM, Peter Peltonen wrote:
I wish to use PostgreSQL with PHP+PDO. I haven't use PDO before.
I have the php-pdo package installed on my CentOS 4.7 server:
# rpm -qa |grep pdo php-pdo-5.1.6-3.el4s1.10
on the command line : php -i | less
should give you more info on what is going on. also make sure the php.ini in /etc/ is the standard distro one and not something custom.
Hi,
On Wed, Aug 5, 2009 at 11:52 AM, Karanbir Singhmail-lists@karan.org wrote:
On 08/04/2009 10:13 PM, Peter Peltonen wrote:
I wish to use PostgreSQL with PHP+PDO. I haven't use PDO before.
I have the php-pdo package installed on my CentOS 4.7 server:
# rpm -qa |grep pdo php-pdo-5.1.6-3.el4s1.10
on the command line : php -i | less
should give you more info on what is going on. also make sure the php.ini in /etc/ is the standard distro one and not something custom.
Thanks! Here seems to lie the problems:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo.so' - /usr/lib/php/modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_mysql.so' - /usr/lib/php/modules/pdo_mysql.so: undefined symbol: pdo_raise_impl_error in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_pgsql.so' - /usr/lib/php/modules/pdo_pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_sqlite.so' - /usr/lib/php/modules/pdo_sqlite.so: undefined symbol: pdo_raise_impl_error in Unknown on line 0
This is strange, because:
# ls -lah /usr/lib/php/modules/pdo.so -rwxr-xr-x 1 root root 91K Apr 7 16:03 /usr/lib/php/modules/pdo.so
# rpm -qf /usr/lib/php/modules/pdo.so php-pdo-5.1.6-3.el4s1.10
So I did:
# rpm -e --nodeps php-pdo php-pgsql
# ls -lah /usr/lib/php/modules/pdo.so ls: /usr/lib/php/modules/pdo.so: No such file or directory
# yum install php-pdo php-pgsql
# ls -lah /usr/lib/php/modules/pdo.so -rwxr-xr-x 1 root root 84K Jul 31 2008 /usr/lib/php/modules/pdo.so
# service httpd restart
And now it seems to work. There must have been something fishy in the previous rpm installation...
Thanks for your help, everyone.
Cheers, Peter