ID:              41435
 User updated by: marques at displague dot com
-Summary:         Half possible
 Reported By:     marques at displague dot com
 Status:          Open
 Bug Type:        Feature/Change Request
 PHP Version:     5.2.2
 New Comment:

I accidentally changed the summary when I added a comment.. It said
"summary was required"..


Previous Comments:
------------------------------------------------------------------------

[2007-05-18 15:10:53] marques at displague dot com

It looks like you can get either host or dbname to come from my.cnf,
but not both, by leaving the value blank in the DSN as the final
parameter.

example:
'mysql:dbname=' will use the database parameter in my.cnf
'mysql:host=' will use the host parameter in my.cnf
'mysql:dbname=:host='
SQLSTATE[42000] [1044] Access denied for user 'myusername'@'localhost'
to database ':host='

'mysql:host=:dbname='
SQLSTATE[HY000] [2005] Unknown MySQL server host ':dbname=

------------------------------------------------------------------------

[2007-05-18 14:52:04] marques at displague dot com

The example should have read: 
$ppv = PDO('mysql',null,null,array(PDO::MYSQL_ATTR_READ_DEFAULT_GROU
P=> 'php');

------------------------------------------------------------------------

[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

Reply via email to