1

So i'm trying to use the PDO module in PHP on a Redhat based distribution (RHEL7) to interact with a database.

In my Php script i have the 'use PDO;' directive, but in the PHP log i get an error : PHP Fatal error: Uncaught Error: Class 'PDO' not found in ...

The extension is uncommented in the php.ini file (extension = pdo.so), i have tried with the relative and the absolute path. I even reinstalled the php-pdo package (yum install), but without success.

I've compared my phpinfo() with a working phpinfo(), and i am missing the PDO section.

I have checked and Apache loads the correct php.ini file

I've passed all my extensions permissions to 755 just to be sure.

I don't get any php warning at startup so i don't know where the problem seems to be.

7
  • did you restart the apache/php-fpm server after installing it? Commented Apr 15, 2019 at 14:52
  • Yes, each time i change anything in my php.ini file i restart my apache server Commented Apr 15, 2019 at 14:53
  • Put phpinfo(); inside your script and provide output Commented Apr 15, 2019 at 15:06
  • When I run phpinfo, I see these options for pdo in the configure command section: '--with-pdo-dblib=/usr/local/opt/freetds' '--with-pdo-mysql=mysqlnd' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--with-pdo-pgsql=/usr/local/opt/libpq' '--with-pdo-sqlite=/usr/local/opt/sqlite' If you don't see something similar to this, try installing the php-mysql package. Commented Apr 15, 2019 at 15:08
  • '--enable-pdo=shared' '--with-pgsql=shared,/usr/pgsql-9.6' '--with-pdo-pgsql=shared,/usr/pgsql-9.6' '--enable-mysqlnd=shared' '--with-mysqli=shared,mysqlnd' '--with-pdo-mysql=shared,mysqlnd' '--with-oci8=shared,/logiciels/php/7.1.4/lib/oic' '--with-pdo-oci=shared,/logiciels/php/7.1.4/lib/oic' '--with-sqlite3=shared' '--with-pdo-sqlite=shared,/usr' Commented Apr 15, 2019 at 15:16

1 Answer 1

2

I found the error : First i started using php in direct command line, and set the env' variable LD_DEBUG=libs:

./php -c /path/to/php.ini /path/to/php/file.php

So with that i was able to get the debug on the dynamic loading of my modules and on the php.ini.

I saw that there was an uncommented line that was blocking the loading of the modules in the INI file, then you have to load the mysql.so module before the pdo_mysql.so and of course restart you apache server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.