Req #67056 [NEW]: '...;dbname =xyz;...' unexpected behavior
| From: | skvsn at ngs dot ru | Date: | Thu, 10 Apr 2014 13:50:47 +0000 |
| Subject: | Req #67056 [NEW]: '...;dbname =xyz;...' unexpected behavior | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185167@lists.php.net to get a copy of this message | ||
From: skvsn at ngs dot ru
Operating system: Ubuntu 13.10
PHP version: Irrelevant
Package: PDO related
Bug Type: Feature/Change Request
Bug description:'...;dbname =xyz;...' unexpected behavior
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 bug report at https://bugs.php.net/bug.php?id=67056&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67056&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67056&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67056&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67056&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67056&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67056&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67056&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67056&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67056&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67056&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67056&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67056&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67056&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67056&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67056&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67056&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67056&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67056&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67056&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67056&r=mysqlcfg