php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71310 Not clear how to enter DSN with special characters
Submitted: 2016-01-08 13:01 UTC Modified: 2017-10-24 08:31 UTC
From: sustmidown at centrum dot cz Assigned:
Status: Open Package: PDO related
PHP Version: 5.6.17 OS: Linux x86-64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sustmidown at centrum dot cz
New email:
PHP Version: OS:

 

 [2016-01-08 13:01 UTC] sustmidown at centrum dot cz
Description:
------------
Manual page: http://www.php.net/pdo.construct
has no information about how to specify DSN parameters with special characters.

For example PostgreSQL supports database names containing slash (/) or even semicolon (;).
How should I encode DSN dbname parameter to connect to a database named "qwer;asdf"?

I tried:

$dsn = 'pgsql:host=127.0.0.1;dbname=asdf;asdf';
$dsn = 'pgsql:host=127.0.0.1;dbname=asdf\;asdf';
$dsn = 'pgsql:host=127.0.0.1;dbname=asdf%3basdf';
$dsn = 'pgsql:host=127.0.0.1;dbname=asdf%3Basdf';

but none of those works.

If I create database named "asdf/asdf", DSN:

$dsn = 'pgsql:host=127.0.0.1;dbname=asdf/asdf';

work, but according to https://pear.php.net/manual/en/package.database.db.intro-dsn.php
you should basicly url-encode parameters.

But both:

$dsn = 'pgsql:host=127.0.0.1;dbname=asdf%2fasdf';
$dsn = 'pgsql:host=127.0.0.1;dbname=asdf%2Fasdf';

do not work.

Expected result:
----------------
PDO constructor should support DSN string that contain database name with semicolon in it.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 08:31 UTC] kalle@php.net
-Package: PDO Core +Package: PDO related
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Oct 17 22:01:26 2018 UTC