 |
Apache2Triad Help, Support and Development The apache2triad help , support and development forums
|
| View previous topic :: View next topic |
| Author |
Message |
milicic.marko
Joined: 18 Mar 2006
Posts: 2
|
| Posted: Sat Mar 18, 2006 4:31 pm Post subject: Please help me to establish PDO connection! |
|
|
Hi, I heard about A2T and I started using it. I an PHP newbie... so don't laugh at me.
I have a big problem. I can't make any PDO connection to MySQL database. I searched extensions directory and found pdo extension. also, I tried the code:
Code: if (!extension_loaded('pdo')) {
throw new Zend_DB_Adapter_Exception('The PDO extension is required for this adapter but not loaded');
}
and I got no exception. So, extension is loaded but when I try to create PDO connection I am faced with this kind of ERROR:
PDOException' with message 'could not find driver' ???????
The code that ties to create PDO object is absolutly correct
<?php
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
?>
PLEASE HELP ME |
|
| Back to top |
|
Vlad Alexa Mancini
Joined: 07 Jul 2003
Posts: 1538
|
| Posted: Sat Mar 18, 2006 5:24 pm Post subject: |
|
|
by default apache2triad is not configured for full pdo support only the basic pdo framework is loaded , the pdo driver you need needs to be loaded
to quote http://php.net/manual/en/ref.pdo.php
Quote: Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.
so in php.ini find extension=php_pdo.dll and after it add
Quote: extension=php_pdo_mssql.dll
your invocation was correct right out of http://php.net/manual/en/function.pdo-construct.php but your other code should be
Code: if (!extension_loaded('pdo_mysql')) {
throw new Zend_DB_Adapter_Exception('The PDO extension is required for this adapter but not loaded');
}
i do not have a tendency to laugh but i have a tendency to advise on reading the documentation
btw , are you sure about using Zend_Db_DataObject ? might not be necesarry |
|
| Back to top |
|
milicic.marko
Joined: 18 Mar 2006
Posts: 2
|
| Posted: Sat Mar 18, 2006 11:42 pm Post subject: |
|
|
Thank you very musc about suggestion. That worked with me.
Quote: btw , are you sure about using Zend_Db_DataObject ? might not be necesarry
I found Zend Framework is very interesting thing. I'm switching from Java/Hibernate programmer to PHP programer and the Zend Framework i thing that MUST be checked out by me :) |
|
| Back to top |
|
| |
|