We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

could not find driver

could not find driver

    $pdo = new Phalcon\Db\Adapter\Pdo\Mysql($config);

Exception : could not find driver

[internal function]: PDO->__construct('mysql:host=127....', .....

My Environment:

CentOS 7 , php7 , mysql 5.7

phalcon installed step as follow:

git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install

my php7 extension as follow:

php -m

[PHP Modules]

bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
pdo_sqlite
phalcon
Phar
readline
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
zip
zlib

[Zend Modules]

Question

I can use native PHP to do...It's correct !

 <?php
    $dsn = "mysql:host=127.0.0.1;dbname=tome_base";
     try {
        $pdo= new PDO($dsn,"tome_base_w","l6_2GHs_01jssRfy_23iJsd",[
            constant('PDO::MYSQL_ATTR_USE_BUFFERED_QUERY') => true,
            constant('PDO::ATTR_PERSISTENT') => true,
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES'utf8';",
        ]);
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
        $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, FALSE);

        $rv = $pdo->query("select * from user", PDO::FETCH_OBJ);
        $d = $rv->fetch();

        var_dump($d);

    } catch (\Exception $ex) {
        echo $ex->getMessage();
    }

but In the Phalcon, It has exception : could not find driver...

Help!!! Thk~~



79.0k
Accepted
answer
edited Aug '16

You need to change order of your PDO and Phalcon extension definition.

Put Phalcon AFTER PDO.

i.e.

/etc/php5/fpm/conf.d/10-pdo.ini
/etc/php5/fpm/conf.d/20-pdo_mysql.ini
/etc/php5/fpm/conf.d/30-phalcon.ini

For instance, such issue is not present on Debian/GNU systems. CentOS is having issues with ordering of loaded extensions.