
April 12th, 2007, 05:37 PM
|
|
|
|
Join Date: Apr 2007
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
MDB2 loadmodule extended
Hi - just trying my first MDB2 and having trouble already.
This works, so I know I've got the right dsn and it's finding MDB2.
php Code:
Original
- php Code |
|
|
|
// Data Source Name: This is the universal connection string $dsn = 'mysql://' . $user . ':' . $pass . '@' . $host . '/' . $mdb2_name; $mdb2 =& MDB2::factory($dsn); $mdb2->loadModule('Extended', null, false); if (PEAR::isError($mdb2)) { echo ($mdb2-> getMessage(). ' - '. $mdb2-> getUserinfo()); } $query ='SELECT * FROM mytable'; // run the query and get a result handler $result = $mdb2->query($query); // check if the query was executed properly if (PEAR::isError($result)) { echo ($result-> getMessage(). ' - '. $result-> getUserinfo()); } // lets just get row:0 and free the result $array = $result->fetchRow(); $result->free();
So far, so good. Now I want to retrieve all the rows. So I decide getAssoc would be the perfect thing. But if I try to use getAssoc, I get the following error:
Call to undefined function: getassoc() in /blah/blah....
Here is my code for getting the Assoc array:
php Code:
Original
- php Code |
|
|
|
$sql = 'SELECT DISTINCT category FROM nrg_categories ORDER BY category'; $arr_categories = & $mdb2->getAssoc($sql);
This has to be easier than I'm making it. Why won't it load the Extended class and why doesn't it give me an error - or am I referencing getAssoc in the wrong way?
|