DB::connect() - proper use - which one?

From: Date: Fri, 23 May 2003 10:22:13 +0000
Subject: DB::connect() - proper use - which one?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5564@lists.php.net to get a copy of this message
Hi I started using the DB-class 6-9 months ago and as far as I remember the suggested code to connect to a database as stated in the documentation was something like this: require_once('DB.php'); $dbinfo = array('phptype' => 'mysql', 'hostspec' => 'localhost', 'database' => 'dbname', 'username' => 'user', 'password' => 'pass'); $db = DB::connect($dbinfo); if (DB::isError($db)) { die ($db->getMessage()); } $db->disconnect(); When I had a look at the (much improved) documentation today I read the following example-code to connect to a database: require_once 'DB.php'; $user = 'user'; $pass = 'pass'; $host = 'localhost'; $db_name = 'dbname'; $dsn = "mysql://$user:$pass@$host/$db_name"; $db = DB::connect($dsn); if (DB::isError($db)) { die ($db->getMessage()); } $db->disconnect(); - What's the difference between these two methods? - Which one should I prefer - How come the method has changed - or has it? (the first method still works fine!) Hope you can help enlighten me on this! Thanks, Tommy Ipsen

« previous php.pear.general (#5564) next »