ltlists wrote:
I'm getting this error when attempting to use setFetchMode()

PHP Fatal error:  Call to undefined method DB_result::setFetchMode()
in new.php on line 27

which means that class DB_result does not have a setFetchMode() method. did you read past the colon (:) in the error message?

did it cross your mind to search for the class that does contain that
method??



My code looks like this for now, almost the same as some of the
samples getting around:

$db = DB::connect("mssql://blah:[EMAIL PROTECTED]/blah");
if (DB::isError($db)) {
        die ($db->getMessage());
}

$res=$db->query("select * from Contacts");
if (DB::isError($res)) { print $res->getMessage() . "\nDetails: "
.$res->getUserInfo();
} else { $res->setFetchMode(DB_FETCHMODE_ASSOC);


If looks as if you are trying to call the setFetchMode() method
on the 'resultset' object in your first example and in your second example (the function) you are calling the same method on the 'db' object..... so this might work better:


$db->setFetchMode(DB_FETCHMODE_ASSOC);

I'm assuming $db is actually a a valid object of class DB

$row=$res->fetchRow();
$field0=$row['ID'];
$field1=$row['Name'];

$res->free();
$db->disconnect();
}


Just incase this could be an installation related problem I should explain that I am using this in a virtual PC environment with IIS6, PEAR was downloaded via a "normal" machine and then copied to the virtual PC and go-pear was run (I think that's it).

A function based connection like this:

function execute_query($db,$sql) {
        debug($sql);
        $db->setFetchMode(DB_FETCHMODE_ASSOC);
        return $db->getAll($sql);
}

seems to return data instead of erroring out.

I'm just a bit lost as to why the first lot of code has a problem
with DB_result.

If anyone can help that would be great. Thanks for your time.


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to