ID: 41435
User updated by: marques at displague dot com
Reported By: marques at displague dot com
Status: Open
Bug Type: Feature/Change Request
PHP Version: 5.2.2
New Comment:
The example should have read:
$ppv = PDO('mysql',null,null,array(PDO::MYSQL_ATTR_READ_DEFAULT_GROU
P=> 'php');
Previous Comments:
------------------------------------------------------------------------
[2007-05-18 14:50:21] marques at displague dot com
Description:
------------
When creating a pdo_mysql connection, database and hostname are
required even when they are supplied in the my.cnf file.
Reproduce code:
---------------
contents of ~/.my.cnf:
[php]
user = myusername
password = mypassword
database = mydb
host = db.mydomain.com
default-character-set = utf8
PHP code to test usage of ~/.my.cnf:
<?
$pdo = new
PDO('mysql:dbname=ppv',null,null,array(PDO::MYSQL_ATTR_READ_DEFAULT_GROUP=>
'php');
$st = $pdo->prepare("select user()");
$st->execute();
$rs = $st->fetchAll();
print_r($rs);
?>
Expected result:
----------------
[EMAIL PROTECTED]
Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message 'invalid
data source name'
In the above example, "dbname" is still required even though a
"database" was given in ~/.my.cnf.
The host given in ~/.my.cnf is also ignored, and PHP/mysql defaults to
"localhost".
Interestingly enough, default_character_set is applied.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41435&edit=1