warn: already posted in general.... with no response... maybe is too
basic.. but I RTFM and still is not clear to me what I am doing wrong....
I want to open a database connection at program initialization and use
that very same connection via globals initilizating ( loading from db)
other objects.
Basically
index.php
require_once ('file.php');
$db=new mysqli(host,us,pass,db);
if(mysqli_connect_errno()){
die('errordb conex');
}
switch ($var){
display1:
$obj=new obj_x();
$obj->load();
$obj->display();
break;
display2:
$obj=new obj_y();
$obj->load();
$obj->display();
break;
}
------------------
class file.php
class obj_x{
function load(){
globals $db;
$sql="select ....);
$ret=$db->query($sql); // XX
...
}
}
fails at XX with Warning: mysqli::query() [function.mysqli-query]:
Couldn't fetch mysqli in class file .... line XX
Any hints ??. I am using php 5.1.6 with linux/ubuntu.
Thanks.
JCG
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php