Dbcore PHP
Dbcore PHP
php
define('dbcore_version','0.1');
define('OBJECT','OBJECT',true);
define('ARRAY_A','ARRAY_A',true);
define('ARRAY_N','ARRAY_N',true);
define('ERR','Your database specific php class file does not contain function ');
class dbCore {
//errors
public $show_errors = true;
public $captured_errors = array();
//log
public $num_queries = 0;
public $last_query = null;
public $last_error = null;
public $col_info = null;
//cache
public $cache_dir = false;
public $cache_queries = false;
public $cache_inserts = false;
public $use_disk_cache = false;
public $cache_timeout = 24; //hours
function __construct() {
echo " hi there.You are in dbcore.php :) ";
}
function connect() {
die(ERR . __FUNCTION__ ."()");
}
function select() {
die(ERR . __FUNCTION__ ."()");
}
function query() {
die(ERR . __FUNCTION__ ."()");
}
function register_error($err_str) {
$this->last_error = $err_str;
$this->captured_errors[] = array
(
'error_str' => $err_str,
'query' => $this->last_query
);
}
function show_errors() {
$this->show_errors = false;
}
function hide_errors() {
$this->show_errors = false;
}
function flush() {
$this->last_result = null;
$this->col_info = null;
$this->last_query = null;
$this->from_disk_cache = false;
}
if ( $this->last_result[$row] ) {
$values = array_values(get_object_vars($this-
>last_result[$row]));
}
if ($output == OBJECT) {
return $this->last_result;
}
elseif ($output == ARRAY_A || $output = ARRAY_N) {
if ($this->last_result) {
$i = 0;
foreach ($this->last_result as $row) {
$new_array[$i] = get_object_vars($row);
if ($output == ARRAY_N) {
$new_array[$i] = array_values($new_array[$i]);
}
$i++;
}
return $new_array;
}
else {
return null;
}
}
//else {
//echo " Invalid $output";
//}
}
function get_col_info($info_type='name',$col_offset=-1) {
if ($this->col_info) {
if ( $col_offset == -1) {
$i = 0;
foreach ($this->col_info as $col) {
$new_array[$i] = $col->{$info_type};
$i++;
}
return $new_array;
}
else {
return $this->col_info[$col_offset]->{$info_type};
}
}
else {
echo " There is no last query executed ";
}
}
function store_cache($query,$is_insert) {
}
function get_cache($query) {
}
function debug() {
}
}
?>