PHP Fatal error: Call to a member function prepare() on a non-object in /opt/hoge/lib/db.inc on line 34
エラー発生個所から少し戻って、ハンドル取得箇所で例外をサボらず表示
<? try { $dbh = new PDO($dsn, $dbuser, $dbpass); } catch (PDOException $e) { var_dump($e); $dbh = null; }
object(PDOException)#2 (8) { ["message":protected]=> string(21) "could not find driver"
ドライバーが無い
$ php -r "phpinfo();" | grep -i pdo
pdo_mysqlがいないとき
/etc/php.d/pdo.ini, /etc/php.d/pdo_sqlite.ini, PDO PDO support => enabled PDO drivers => sqlite pdo_sqlite PDO Driver for SQLite 3.x => enabled
pdo_mysqlがいるとき
/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 => enabled pdo_sqlite PDO Driver for SQLite 3.x => enabled
http://mirror.centos.org/centos/6/updates/x86_64/Packages/
# rpm -ivh php-mysql-5.3.3-27.el6_5.x86_64.rpm