Solved

The PDO extension is required for this adapter but the extension is not loaded

Posted on 2009-04-07
10
3,290 Views
Last Modified: 2013-11-10
I get the following error when trying to connect to a Postgresql database. In phpinfo there is no mention of postgresql, pgsql or pdo. Looking in the files of XAMPP/PHP (5.2.3), I can find the file php_pgsql.dll. I've uncommented the line "extension=php_pgsql.dll" in php.ini (there are two of those), but it won't work. Any ideas?

Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message
'The PDO extension is required for this adapter but the extension is not loaded' in
D:\web\zend1\library\Zend\Db\Adapter\Pdo\Abstract.php:107 Stack trace: #0
D:\web\zend1\library\Zend\Db\Adapter\Abstract.php(770): Zend_Db_Adapter_Pdo_Abstract->_connect() #1
D:\web\zend1\library\Zend\Db\Adapter\Pdo\Pgsql.php(151): Zend_Db_Adapter_Abstract->quote('albums') #2
D:\web\zend1\library\Zend\Db\Table\Abstract.php(696): Zend_Db_Adapter_Pdo_Pgsql->describeTable('albums', NULL) #3
D:\web\zend1\library\Zend\Db\Table\Abstract.php(739): Zend_Db_Table_Abstract->_setupMetadata() #4 D:\web\zend1\library\Zend\Db\Table\Abstract.php(846):
Zend_Db_Table_Abstract->_setupPrimaryKey() #5 D:\web\zend1\library\Zend\Db\Table\Select.php(99):
Zend_Db_Table_Abstract->info() #6 D:\web\zend1\library\Zend\Db\Table\Select.php(77):
Zend_Db_Table_Select->setTable(Object(Albums)) #7 D:\web\zend1\library\Zend\Db\Table\Abstract.php(881):
Zend_Db_Table_Select->__construct(Object(Albums)) #8 in
D:\web\zend1\library\Zend\Db\Adapter\Pdo\Abstract.php on line 107
0
Comment
Question by:R7AF
  • 5
  • 3
  • 2
10 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 24086957
ZF needs the pdo so you need to activate first thte php_pdo.dll and then the pdo pgsql dll must be loaded.

See http://www.php.net/manual/en/ref.pdo-pgsql.php
0
 
LVL 13

Author Comment

by:R7AF
ID: 24087178
I have the following extensions enabled. After restarting Apache it still doesn't work. (And I searched both php.ini for "pg" to see if I missed something, but couldn't find anything strange.)
extension=php_pdo.dll
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll

Open in new window

0
 
LVL 3

Expert Comment

by:sreindl04
ID: 24090540
We've had the same problem. For whatever reason he pg libraries are not parsing the path correctly (at least it seems so). Please copy the *.dll files from the postgres bin directory to the apache bin folder.

PLEASE MAKE BACKUPS BEFORE AND DO NOT OVERWRITE EXISITING FILES.

That helped at least for our site.

The drawback of this solution is that whenever you upgrade your postgres you should also hav to update the dll files manuall.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 13

Author Comment

by:R7AF
ID: 24094797
Thanks for the tip. I've tried it but it doesn't work. In the end I copied all postgresql bin-files to the apache bin, but no change. But looking at the path still might be a good idea.
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 24094803
check the error log of apache,
make sure the postgres library directory is present in PATH (you need to reboot the server after you change the global settings for PATH, *yeah windows*) so no need to copy libs if you setup PATH correctly
0
 
LVL 3

Expert Comment

by:sreindl04
ID: 24094845
Using the path variable didn't work for us.
0
 
LVL 13

Author Comment

by:R7AF
ID: 24095170
I've changed the path, but that didn't fix it. The logs show some errors though:

PHP Warning:  PHP Startup: pdo_pgsql: Unable to initialize module\nModule compiled with module API=20060613, debug=0, thread-safety=0\nPHP    
compiled with module API=20060613, debug=0, thread-safety=1\nThese options need to match\n in Unknown on line 0
PHP Warning:  PHP Startup: pgsql: Unable to initialize module\nModule compiled with module API=20060613, debug=0, thread-safety=0\nPHP    
compiled with module API=20060613, debug=0, thread-safety=1\nThese options need to match\n in Unknown on line 0
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 500 total points
ID: 24095185
So your php_*.dll do not match the installed PHP version. You need to fix either your extension_dir or correctly install and configure your PHP
The php_*.dll needs to be from the zip/installer of your used PHP.
0
 
LVL 13

Author Comment

by:R7AF
ID: 24095521
I found the cause of the problem. The php.ini loaded is not in the XAMPP folder, but in the Zend folder:

C:\Program Files\Zend\Core\etc\php.ini

I installed Zend Core, but still use XAMPP. For some reason XAMPP uses the php.ini from the Zend Core Apache installation. I removed the zend/core/etc from the Windows PATH, but it still loads. Using the Zend Apache, the page works and I can see data from the database. Now I need to decide how to fix this so it works like I want to.
0
 
LVL 13

Author Comment

by:R7AF
ID: 24097297
For those interested, I posted another question about this...
http://www.experts-exchange.com/Q_24305514.html
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php convert date format 3 21
PHP and google maps 13 45
ignore other .htaccess 2 45
two ways encryption with php 3 28
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question