PDO

pecl::PDO

AdvancedSearch | AreaMap ]

Search:

  Welcome   Installation   FAQ   User Notes   Links  
  User Notes   bindParam   DSN   exec   API differences   fetchCol   setAttribute   API  

Username:

Password:


Areas In
This Wiki

BEPHPUG

Conferences

emPHPower

LiveUser

Main

MDB2

PDO

PHPSVN

PHPTODO

RDBMS

WebBuilder2

DSN

Using PDO you have to use a DSN-String to connect to the database:


<?php
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
$dbh = new PDO($dsn, $user, $password);

?>

But that's not nice if you have to parse config files for example. It would be nice to config DB-settings using an array as PEAR::DB, or parameters as ADOdb..., too!

PEAR::DB style:


<?php
$dsn = array(
    'phptype'  => 'mysql',
    'hostspec' => '127.0.0.1',
    'database' => 'testdb'
);
$user = 'dbuser';
$password = 'dbpass';
$dbh = new PDO($dsn, $user, $password);
?>

Furthermore it would be very beneficial to also support the PEAR DSN format since its well established and documented:
http://pear.php.net/manual/en/package.database.db.intro-dsn.php

PDO:DSN (212.202.40.148)
Thu, 17 Mar 2005, 16:18
[ Links | Source | History | RSS ]

This site powered by YaWiki 0.22 beta.


anonymous
2007-09-26 00:27:25 (406)
PEAR DSN format is nice, but it includes the user password. In my opinion, it's best to keep this out of the DSN and out of the object entirely. That way, it doesn't show up on print_r/var_dump. PDO does a nice job of keeping the user name and password separate. I like that.
anonymous
2005-12-30 02:57:40 (79)
sod pear; we are looking forwards to a new future - not backwards. get a -beep- grip would you...
jlim [AT] natsoft [DOT] com [DOT] my
2005-03-17 10:58:57 (9)
> very beneficial to also support the PEAR DSN Respecting the past is important. Even ADOdb supports it!

Add A Comment
Email:
*Comment:
Catpcha:
* denotes required field

Your comment will be added immediately; please check your comments, and be nice. :-)

Please use plain text only; HTML and PHP code will be converted to entities.

Your email address will be obfuscated with [AT] and [DOT] after you post your comment.