DB class modified to fit advanced development mode
This commit is contained in:
parent
b0b4abd508
commit
d40b8832b6
1 changed files with 53 additions and 6 deletions
|
@ -55,7 +55,16 @@ class Clipbucket_db
|
|||
*/
|
||||
|
||||
function _select($query) {
|
||||
global $__devmsgs;
|
||||
if (is_array($__devmsgs)) {
|
||||
$start = microtime();
|
||||
$result = $this->mysqli->query($query);
|
||||
$end = microtime();
|
||||
$timetook = $end - $start;
|
||||
devWitch($query, 'select', $timetook);
|
||||
} else {
|
||||
$result = $this->mysqli->query($query);
|
||||
}
|
||||
$this->num_rows = $result->num_rows ;
|
||||
$data = array();
|
||||
|
||||
|
@ -84,6 +93,8 @@ class Clipbucket_db
|
|||
|
||||
function select($tbl,$fields='*',$cond=false,$limit=false,$order=false,$ep=false) {
|
||||
//return dbselect($tbl,$fields,$cond,$limit,$order);
|
||||
global $__devmsgs;
|
||||
|
||||
$query_params = '';
|
||||
//Making Condition possible
|
||||
if($cond)
|
||||
|
@ -102,8 +113,17 @@ class Clipbucket_db
|
|||
$query_params .= " LIMIT $limit ";
|
||||
|
||||
$query = " SELECT $fields FROM $tbl $query_params $ep ";
|
||||
if (is_array($__devmsgs)) {
|
||||
$start = microtime();
|
||||
$data = $this->_select($query);
|
||||
$end = microtime();
|
||||
$timetook = $end - $start;
|
||||
devWitch($query, 'select', $timetook);
|
||||
return $data;
|
||||
} else {
|
||||
return $this->_select($query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count values in given table using MySQL COUNT
|
||||
|
@ -115,11 +135,19 @@ class Clipbucket_db
|
|||
*/
|
||||
|
||||
function count($tbl,$fields='*',$cond=false) {
|
||||
global $db;
|
||||
global $db,$__devmsgs;
|
||||
if ($cond)
|
||||
$condition = " Where $cond ";
|
||||
$query = "Select Count($fields) From $tbl $condition";
|
||||
if (is_array($__devmsgs)) {
|
||||
$start = microtime();
|
||||
$result = $this->_select($query);
|
||||
$end = microtime();
|
||||
$timetook = $end - $start;
|
||||
devWitch($query, 'count', $timetook);
|
||||
} else {
|
||||
$result = $this->_select($query);
|
||||
}
|
||||
$fields = $result[0];
|
||||
|
||||
if ($fields)
|
||||
|
@ -150,8 +178,18 @@ class Clipbucket_db
|
|||
|
||||
function Execute($query)
|
||||
{
|
||||
global $__devmsgs;
|
||||
try {
|
||||
if (is_array($__devmsgs)) {
|
||||
$start = microtime();
|
||||
$data = $this->mysqli->query($query);
|
||||
$end = microtime();
|
||||
$timetook = $end - $start;
|
||||
devWitch($query, 'execute', $timetook);
|
||||
return $data;
|
||||
} else {
|
||||
return $this->mysqli->query($query);
|
||||
}
|
||||
} catch(DB_Exception $e) {
|
||||
$e->getError();
|
||||
}
|
||||
|
@ -169,6 +207,7 @@ class Clipbucket_db
|
|||
*/
|
||||
|
||||
function update($tbl,$flds,$vls,$cond,$ep=NULL) {
|
||||
global $__devmsgs;
|
||||
# handling ( ' ) in title problem (ex: you can't)
|
||||
if (strpos($vls[0], "'")) {
|
||||
$vls[0] = str_replace("'", "'", $vls[0]);
|
||||
|
@ -204,7 +243,15 @@ class Clipbucket_db
|
|||
$this->total_queries_sql[] = $query;
|
||||
|
||||
try {
|
||||
if (is_array($__devmsgs)) {
|
||||
$start = microtime();
|
||||
$this->mysqli->query($query);
|
||||
$end = microtime();
|
||||
$timetook = $end - $start;
|
||||
devWitch($query, 'update', $timetook);
|
||||
} else {
|
||||
$this->mysqli->query($query);
|
||||
}
|
||||
} catch(DB_Exception $e) {
|
||||
$e->getError();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue