tags:

views:

220

answers:

1

Hi!

In past i use adodb for mysql in php. Now i wont to use PDO. How can i quick switch from adodb query to pdo using one connection to datebase?

+1  A: 

You may want to check the following two examples:

#PDO script:
$db = new PDO("mysql:dbname=you_db_name;host=127.0.0.1", "root", "");
$rs = $db->query("SELECT * FROM table")->fetchAll(PDO::FETCH_ASSOC);
foreach($rs as $r) {}

#ADOdb script
require_once("adodb5/adodb.inc.php");
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$db = NewADOConnection("mysql://root:@127.0.0.1/you_db_name");
$rs = $db->Execute("SELECT * FROM table");
foreach($rs as $r) {}

Note that PDO is a native compiled library and not loaded at runtime.

Daniel Vassallo
it's not working . ;(
gummmibear
What kind of error are you receiving?
Daniel Vassallo