Error:
Fatal error: Call to undefined method waDatabase::executeQuery() in V:\xampp\htdocs\webArts\webArts\lib\db\db.php on line 75
I know what to do to fix it just remove "$db->executeQuery('SELECT * FORM test');" but thats not what i want to do i want that to actually run the executeQuery from mysqlConnection
<?php
define ('DB_BASE_DIR', dirname(__FILE__));
if(!defined('DS')){
define('DS', DIRECTORY_SEPARATOR);
}
class waDatabase {
function connect($info){
$name = (isset($info['name'])) ? $info['name'] : 'default';
$info['driver'] = strtolower($info['driver']); // For those who like CAPS...
if(!isset($info['driver'])){ // Was there a driver provided?
return trigger_error('No database driver specified', E_USER_ERROR);
}
$driver = DB_BASE_DIR . DS . 'drivers' . DS . $info['driver'] . '_driver.php';
$class = $info['driver'] . 'Connection';
if(!is_readable($driver)){ // Does the driver file exist?
return trigger_error('Database driver does not exist: ' . $info['driver'] . '_driver.php', E_USER_ERROR);
}
require_once($driver); // Require the database driver.
if(!class_exists($class)){ // Does the driver file contain the correct class?
return trigger_error('Database driver does not exist: ' . $info['driver'] . '_driver.php', E_USER_ERROR);
}
$dbd = new $class();
if(!is_a($dbd, 'waDbConnection')){ // Does the class extend waDbConnection?
return trigger_error('Database driver does not extend waDbConnection: ' . $info['driver'] . '_driver.php', E_USER_ERROR);
}
// Error is thrown in the constructor (hopefully).
$dbd->open($info);
}
}
class waDbConnection {
var $_dbinfo;
function waDbConnection(){
}
function close(){
assert(FALSE);
}
function connect($dbinfo){
assert(FALSE);
}
function executeQuery($query){
assert(FALSE);
}
function getRow($stmt, $args = array()){
$result = $this->executeQuery($stmt, $args);
$result->next();
return $result->current();
}
function open($dbinfo) {
if($ret = $this->connect($dbinfo)){
$this->_dbinfo = $dbinfo;
return true;
}
}
}
$db = new waDatabase;
$info = array(
'driver' => 'MySQL',
'function' => 'mysql_connect',
'host' => 'localhost',
'user' => 'labs',
'password' => '965478',
'database' => 'labs'
);
$db->connect($info);
$db->executeQuery('SELECT * FROM test');
?>
and drivres/mysql_driver.php
<?php
class mysqlConnection extends waDbConnection{
var $_link;
function mysqlConnection(){
parent::waDbConnection();
if(!extension_loaded('mysql')){
trigger_error('The MySQL extension is not loaded.', E_USER_ERROR);
}
}
function connect($dbinfo){
if(is_array($dbinfo)){
switch($dbinfo['function']){
case 'mysql_connect';
$link = mysql_connect($dbinfo['host'], $dbinfo['user'], $dbinfo['password']) or trigger_error(mysql_error(),E_USER_ERROR);
break;
case 'mysql_pconnect';
$link = mysql_pconnect($dbinfo['host'], $dbinfo['user'], $dbinfo['password']) or trigger_error(mysql_error(),E_USER_ERROR);
break;
default:
trigger_error('No driver function or Invalid driver function supplied.',E_USER_ERROR);
}
mysql_select_db($dbinfo['database'], $link) or trigger_error(mysql_error(),E_USER_ERROR);
$this->_link = $link;
return true;
}
}
function close(){
$this->isConnect();
mysql_close($this->_link);
return true;
}
function executeQuery($query){
$this->isConnect();
mysql_query($query);
return true;
}
function getInsertId() {
return mysql_insert_id($this->_link);
}
function isConnect(){
if(!$this->_link){
trigger_error('Error: Not connected', E_USER_ERROR);
}
return true;
}
}
?>
Edited by Koncept, 15 July 2006 - 12:29 AM.
