<?php
//by kuiGG www.kuigg.com
class kuigg_Db {
function tbname($tb)
{
return “kuigg_{$tb}”;
}
function getdata ($arr , $separator = ‘,’) {
$str = $s = ”;
foreach ($arr as $k => $v) {
$str .= $s.”`{$k}`=’{$v}’”;
$s = $separator;
}
return $str;
}
function count ($tb , $fields = ‘*’ , $terms = ”){
$o = & self::in();
$tb= self::tbname($tb);
$where = empty($terms) ? ’1′ : $terms;
$query = “select count({$fields}) from `{$tb}` where {$where}”;
return $o->getVar($query);
}
function fetchdata ($tb , $fields = ‘*’ , $terms = ”){
$o = & self::in();
$tb= self::tbname($tb);
$data = array();
$query = “select {$fields} from `{$tb}` {$terms}”;
return $o->getData($query);
}
function fetchrow ($tb , $fields = ‘*’ , $terms = ”){
$o = & self::in();
$tb= self::tbname($tb);
$data = array();
$query = “select {$fields} from `{$tb}` {$terms}”;
return $o->getLine($query);
}
function fetchitem ($tb , $field , $terms = ”){
$o = & self::in();
$tb= self::tbname($tb);
$data = array();
$query = “select {$field} from `{$tb}` {$terms}”;
return $o->getVar($query);
}
function insert($tb, $arr, $getinsertid = false, $replace = false) {
$o = & self::in();
$tb= self::tbname($tb);
$data = self::getdata($arr);
$cmd = $replace ? ‘REPLACE INTO’ : ‘INSERT INTO’;
$silence = $silence ? ‘SILENT’ : ”;
$query = “{$cmd} `{$tb}` SET {$data}”;
$return = $o->runSql($query);
return $getinsertid ? $o->lastId() : $return;
}
function insert_id() {
$o = & self::in();
return $o->lastId();
}
function update($tb, $arr, $terms = NULL , $getarows = false , $low_priority = false) {
$o = & self::in();
$tb= self::tbname($tb);
$data = self::getdata($arr);
$cmd = “UPDATE “.($low_priority ? ‘LOW_PRIORITY’ : ”);
$where = empty($terms) ? ’1′ : $terms;
$query = “{$cmd} `{$tb}` SET {$data} WHERE {$where}”;
$return = $o->runSql($query);
return $getarows ? $o->affectedRows() : $return;
}
function delete($tb, $terms = NULL,$getarows = false, $limit = 0) {
$o = & self::in();
$tb = self::tbname($tb);
$where = empty($terms) ? ’1′ : $terms;
$query = “DELETE FROM `{$tb}` WHERE {$where} “.($limit ? “LIMIT {$limit}” : ”);
$return = $o->runSql($query);
return $getarows ? $o->affectedRows() : $return;
}
function affected_rows() {
$o = & self::in();
return $o->affectedRows();
}
function query($query) {
$o = & self::in();
return $o->runSql($query);
}
function &in() {
static $object;
if(empty($object)) {
$object = new SaeMysql();
}
return $object;
}
}
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.28, 5.4.0 - 5.4.27
- Parse error: syntax error, unexpected '{' in /in/RP9gJ on line 7
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '{' in /in/RP9gJ on line 7
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/RP9gJ on line 7
Process exited with code 255.
preferences:
206.77 ms | 1395 KiB | 117 Q