I've to access an external DB (MS SQL so it is too complicated to rewrite the DB layer... bla bla)
So I plugged in my class to be seen inside hooks...
//catalog_base.inc $param="salve";
class Catalog_DB { function __construct($DBParam) { //... } public function test() { print("<!-- ciao ciao -->"); } }
$DBGorilla=new Catalog_DB($param);
//catalog.module $path = drupal_get_path('module', 'catalog'); require_once($path . '/catalog_base.inc');
//... hooks etc...
//test1 $DBGorilla->test();
function catalog_asearch() { global $DBGorilla; //test2 $DBGorilla->test(); $query=$DBGorilla->test(); return ""; }
test1 succeed test2 fail with Call to a member function test() on a non-object in ...
using $GLOBALS makes no difference... but drupal code is plenty of
global $user;
in functions
what's wrong?
thx