Server IP : 43.241.58.20 / Your IP : 216.73.216.25 Web Server : Apache/2 System : Linux ns1-1556229.dragonhispeed.com 3.16.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : ratsitne ( 1130) 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/ratsitne/domains/tessabalpatiu.go.th/public_html/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 "<pre>".$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; } } //---- function getJoin( $col, $join, $where, $order = "", $option = "" ) { $sql = " SELECT " . ($col) . " FROM $join ".( $where ? "WHERE $where" : "" )." ".($order)." ".($option).""; //echo $sql; //exit; $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 "; foreach ($arrData as $key => $val) { //if($val){ $sql.=" $key = '$val' ".(count($arrData)-1 != $i ? ", " : " "); //} $i++; } $sql.="WHERE $where"; //echo $sql."<br>"; $res = $this->conn->sql_query($sql) or $this->conn->sqlError(__FILE__, __LINE__); if($res){ return $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; } } } ?>