#41435 [NEW]: my.cnf database and host values are ignored in pdo_mysql
| From: | marques at displague dot com | Date: | Fri, 18 May 2007 14:50:21 +0000 |
| Subject: | #41435 [NEW]: my.cnf database and host values are ignored in pdo_mysql | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-112836@lists.php.net to get a copy of this message | ||
From: marques at displague dot com
Operating system:
PHP version: 5.2.2
PHP Bug Type: Feature/Change Request
Bug description: my.cnf database and host values are ignored in pdo_mysql
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:
----------------
myusername@db.mydomain.com
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 bug report at http://bugs.php.net/?id=41435&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41435&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41435&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41435&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41435&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41435&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41435&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41435&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41435&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41435&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41435&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41435&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41435&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41435&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41435&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41435&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41435&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41435&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41435&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41435&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41435&r=mysqlcfg