Req #67056 [Com]: '...;dbname =xyz;...' unexpected behavior

From: Date: Thu, 10 Apr 2014 13:52:14 +0000
Subject: Req #67056 [Com]: '...;dbname =xyz;...' unexpected behavior
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185168@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67056&edit=1 ID: 67056 Comment by: skvsn at ngs dot ru Reported by: skvsn at ngs dot ru Summary: '...;dbname =xyz;...' unexpected behavior Status: Open Type: Feature/Change Request Package: PDO related Operating System: Ubuntu 13.10 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:03:35) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans Previous Comments: ------------------------------------------------------------------------ [2014-04-10 13:50:46] skvsn at ngs dot ru Description: ------------ PDO constructor would fail to understand you give database name, provided you pass $dsn like '...;dbname =xyz;...', i.e. in case there's a whitespace in between "dbname" and "=". Test script: --------------- $pdo = new \PDO("mysql:host=localhost;port=3306;dbname =$dbname;charset=utf8", $username, $password); $sth = $pdo->query("select * from $tablename"); var_dump($a->errorInfo()); Actual result: -------------- // var_dump dsn: string 'mysql:host=localhost;port=3306;dbname =mydatabase;charset=utf8' (length=66) // var_dump username string 'theuser' (length=14) // var_dump password string 'thepassword' (length=6) // var_dump pdo->errorInfo() array (size=3) 0 => string '3D000' (length=5) 1 => int 1046 2 => string 'No database selected' (length=20) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67056&edit=1

« previous php.bugs (#185168) next »