Problem: Doctrine test application isn't working because of driver issue.
Setup: Mac OS X 10.5.7 (not server), MAMP 1.7.2, Doctrine 2.2.1, PHP 5.2.6
I am following the doctrine documentation to try to set up a development environment on my local machine. The output of running the page from the web (through MAMP) shows an empty screen (I am assuming because errors are not shown through MAMP). If I run the page on my test environment (Debian Lenny) everything works perfectly and there is output on the screen.
I have been trying to figure it out for hours and I haven't been able to. Any insight is appreciated.
Here is the output when run from the command line.
justingiboney$ php test.php
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /Applications/MAMP/htdocs/doctrine_test_site/bootstrap.php:16
Stack trace:
#0 /Applications/MAMP/htdocs/doctrine_test_site/bootstrap.php(16): PDO->__construct('mysql:dbname=fa...', '****', '****')
#1 /Applications/MAMP/htdocs/doctrine_test_site/test.php(4): require_once('/Applications/M...')
#2 {main}
thrown in /Applications/MAMP/htdocs/doctrine_test_site/bootstrap.php on line 16
Here is test.php
<?php
// test.php
require_once('bootstrap.php');
$conn->export->createTable('test', array('name' => array('type' => 'string')));
$conn->execute('INSERT INTO test (name) VALUES (?)', array('jwage'));
$stmt = $conn->prepare('SELECT * FROM test');
$stmt->execute();
$results = $stmt->fetchAll();
print_r($results);
?>
Here is bootstrap.php
<?php
// bootstrap.php
/**
* Bootstrap Doctrine.php, register autoloader specify
* configuration attributes and load models.
*/
require_once(dirname(__FILE__) . '/lib/vendor/doctrine/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
$dsn = 'mysql:dbname=****;host=127.0.0.1:8889';
$user = '****';
$password = '****';
$dbh = new PDO($dsn, $user, $password);
$conn = Doctrine_Manager::connection($dbh);
$conn->setOption('****', $user);
$conn->setOption('****', $password);
?>
If I run phpinfo() through the MAMP page I see a few lines that make it look like PDO-MySQL is installed
--with-pdo-mysql=shared,/Applications/MAMP/Library
PDO drivers | sqlite2, sqlite, pgsql, mysql
PDO Driver for MySQL, client library version 5.0.41