coldkill Posted April 1, 2006 Share Posted April 1, 2006 I made a class which has all my database stuff in like connection, querying, fetching stuff etc etc but with the connect it doesn't accept the vars $this->obj['sql_usr'] etc etc. Everything else appears to work find except this function which i have now changed the var names to the actual values so it will work. Any ideas?Thanks in advance,ColdHeres the code of the function[code]/*-------------------------------------------------------------------------*/ // Connect to the db /*-------------------------------------------------------------------------*/ function connect() { if( $this->obj['persistant'] ) { $this->connection_id = mysql_pconnect( "localhost" , "---" , "---" , 0 ); } else { $this->connection_id = mysql_connect( "localhost" , "---" , "---" , 0 ); } if( ! $this->connection_id ) { $this->fatal_error(); return FALSE; } if ( ! mysql_select_db("cold_coldfire") ) { $this->fatal_error(); return FALSE; } return TRUE; }[/code]The function is called on the index with[code]$cfclass->init_db_conn();[/code]The function "init_db_conn" is in another calling file with this code[code]//================================= // INIT: DB //================================= function init_db_conn(){ $this->vars['sql_type'] = ! $this->vars['sql_type'] ? 'mysql' : strtolower($this->vars['sql_type']); require_once( KERNEL_PATH.'class_db.php' ); //<- page with the connect function /** * New DB driver */ $this->DB = new db_driver; /** * Set DB vars */ $this->DB->obj['sql_db'] = $this->vars['sql_db']; $this->DB->obj['sql_usr'] = $this->vars['sql_user']; $this->DB->obj['sql_host'] = $this->vars['sql_host']; $this->DB->obj['sql_pass'] = $this->vars['sql_pass']; $this->DB->obj['sql_type'] = $this->vars['sql_type']; $this->DB->obj['persistant'] = '0'; /** * Load query file */ $this->DB->obj['sql_query_file'] = ROOT_PATH.'sources/sql/'.$this->vars['sql_type'].'_queries.php'; /** * Constants */ define( "SQL_TYPE" , $this->vars['sql_type'] ); define( "DB_CLASS_LOADED" , TRUE ); /** * Connect to the db... finally ¬¬ */ $this->DB->connect(); $this->db_conn = '1'; /** * All done :D */ if( ! defined( "DB_LOADED" ) ) { define( "DB_LOADED" , TRUE ); } }[/code] Quote Link to comment Share on other sites More sharing options...
coldkill Posted April 2, 2006 Author Share Posted April 2, 2006 To add to my problem:I've tried making another class and accessing the query function (which works in the other places it exists) using $cfclass->DB->query("QUERY"); but i get this error [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Fatal error: Call to a member function on a non-object in /home/cold/public_html/kernel/class_temp.php on line 50[/quote]I am using extends cfclasses to get the function but it still doesn't work. Any ideas?Thanks,Cold Quote Link to comment Share on other sites More sharing options...
coldkill Posted April 2, 2006 Author Share Posted April 2, 2006 OK it seems to only not work with class psuedo vars ie $this->var['sql_user'] etc etc. Any ideas? Quote Link to comment Share on other sites More sharing options...
trq Posted April 2, 2006 Share Posted April 2, 2006 Where going to need to see more code. As isits very difficult to see what is going on. Do you have a property [i]obj[/i] defined? Quote Link to comment Share on other sites More sharing options...
coldkill Posted April 2, 2006 Author Share Posted April 2, 2006 Yep:[code]/*** DB Object array* Holds key information*/var $obj = array( "sql_db" => "" , "sql_user" => "root" , "sql_pass" => "" , "sql_host" => "localhost" , "persistant" => "0" , "sql_type" => "mysql" , "cached_queries" => array() , "sql_query_file" => "" , "force_new" => 0 );[/code]All the information does get to the function but for some reason it still doesn't work. I tried echoing a few of the obj values and they all displayed properly. Quote Link to comment Share on other sites More sharing options...
coldkill Posted April 3, 2006 Author Share Posted April 3, 2006 ::Bumb::Still need help please. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.