| Server IP : 27.254.152.13 / Your IP : 216.73.217.38 Web Server : Apache/2 System : Linux ns1-252017.dragonhispeed.com 5.2.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : coloflew ( 1072) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/coloflew/.trash/files/fulltion.co.th/public_html/parcel/tester/lib/class/ |
Upload File : |
<?php
class SC_Query {
var $conn;
var $option;
var $where;
var $groupby;
var $order;
//----
function SC_Query() {
$objConn = new SQL_DB();
$this->conn = $objConn;
$this->where = "";
}
//----
function getCount($table, $where = "", $order = "", $option = "" ) {
if(strlen($where) <= 0) {
$sql = "SELECT COUNT(*) as Total FROM ".DB_PREFIX."$table";
} else {
$sql = "SELECT COUNT(*) as Total FROM ".DB_PREFIX."$table WHERE $where";
}
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
$arr=$this->conn->sql_fetchassoc($res);
//print_r($arr);
return $arr;
}
//----
function getAll( $table, $col, $where = "", $order = "", $option = "" ) {
$sql = " SELECT " . ($col) . " FROM ".DB_PREFIX."$table ".( $where ? "WHERE $where" : "" )." ".($order)." ".($option)."";
//echo $sql."<br>";
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if( $this->conn->sql_numrows($res) ){
while ($arr=$this->conn->sql_fetchassoc($res)){
$arrRet[]= $arr;
}
return $arrRet;
}
}
//----
function getJoin( $col, $join, $where, $order = "", $option = "" ) {
$sql = " SELECT " . ($col) . " FROM $join ".( $where ? "WHERE $where" : "" )." ".($order)." ".($option)."";
//echo "==>".$sql."<Br>";
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if( $this->conn->sql_numrows($res) ){
while ($arr=$this->conn->sql_fetchassoc($res)){
$arrRet[]= $arr;
}
return $arrRet;
}
}
//----
function getOne( $table, $col, $where ) {
$sql = " SELECT " . ($col) . " FROM ".DB_PREFIX."$table ".($where ? "WHERE $where" : "")." ";
//echo $sql;
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if( $this->conn->sql_numrows($res) ){
while ($arr=$this->conn->sql_fetchassoc($res)){
$arrRet= $arr;
}
return $arrRet;
}
//echo"<pre>".$sql;
}
//----
function insertData( $table, $arrData =array() ) {
$sql = "INSERT INTO ".DB_PREFIX."".$table." (" . implode(', ', array_keys($arrData)) . ") VALUES ('" . implode("', '", $arrData) . "') ";
//echo $sql;
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if($res){
return $this->conn->sql_nextid();
}else{
return false;
}
}
//----
function updateData( $table, $arrData =array(), $where) {
$i = 0;
$sql="UPDATE ".DB_PREFIX."".$table." SET ";
//echo 123;
foreach ($arrData as $key => $val)
{
//if($val){
$sql.=" $key = '$val' ".(count($arrData)-1 != $i ? ", " : " ");
//}
$i++;
}
$sql.="WHERE $where";
//echo $sql;
//echo ">>".$_GET['lang'];
//echo "pp=>".$sql; exit;
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if($res){
return $res;
}
echo"<pre>".print_r($res);
}
//----
function deleteData( $table, $where ) {
$sql = "DELETE FROM ".DB_PREFIX."".$table." WHERE " . $where . " ";
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
//echo "<pre>".print_r($res);
if($res){
$this->conn->sql_query("OPTIMIZE TABLE ".DB_PREFIX."$table") or $this->conn->sqlError(__FILE__, __LINE__);
return $res;
}else{
return false;
}
}
//----
function gettest( $sql ) {
//$sql = " SELECT " . ($col) . " FROM ".DB_PREFIX."$table ".($where ? "WHERE $where" : "")." ";
//echo $sql;
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if( $this->conn->sql_numrows($res) ){
while ($arr=$this->conn->sql_fetchassoc($res)){
$arrRet= $arr;
}
return $arrRet;
}
//echo"<pre>".$sql;
}
//----
function gettest2( $sql ) {
//$sql = " SELECT " . ($col) . " FROM ".DB_PREFIX."$table ".($where ? "WHERE $where" : "")." ";
//echo $sql;
$res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__);
if( $this->conn->sql_numrows($res) ){
while ($arr=$this->conn->sql_fetchassoc($res)){
$arrRet[]= $arr;
}
return $arrRet;
}
//echo"<pre>".$sql;
}
}
?>