Jump to content

AdoDB problem


Utherr12
 Share

Recommended Posts

function db_init() {  $db = NewADOConnection(pref_getServerPreference('database'));  if (!$db) {	die("Connection failed");  }  ADOdb_Active_Record::SetDatabaseAdapter($db);  $db->Execute('set names utf8');  $GLOBALS['db'] = $db;  $db->debug = true; //just for debug}function db_changeDatabase($dbName) {  $dbName = addslashes($dbName);  db_init();  return logged_query("use $dbName");}function db_getArrayAssoc($query) {  return $GLOBALS['db']->GetAssoc($query);}

echo db_changeDatabase('DEX');$max_words = db_getSingleValue("SELECT COUNT(*) as words FROM `Definition`");echo $random_w = rand(0,$max_words);$WordWithID = db_getArrayAssoc("SELECT * FROM `Definition` WHERE `id`='$random_w'");echo "<br /><br />".$WordWithID;

The above piece of code doesn't work /facepalm. $WordWithID returns "Array".

Link to comment
Share on other sites

That's becase $WordWithID is an array - when you echo an array, it prints "Array".

Link to comment
Share on other sites

Ok then... how does GetAssoc() returns the array? Obviously it doesn't work like mysql_fetch_assoc.

foreach ($WordWithID as $content )  echo $content;

Displays ArrayArray.

Edited by KingA
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...