Example #1
0
 public function ex_sqlx($sql, $close = TRUE)
 {
     $sql = mysql_class::arabicToPersian($sql);
     $conf = new conf();
     $host = $conf->host;
     $db = $conf->db;
     $user = $conf->user;
     $pass = $conf->pass;
     if (isset($this) && get_class($this) == __CLASS__) {
         if (isset($this->ex_db) && $this->ex_db) {
             $host = $this->host;
             $user = $this->user;
             $pass = $this->pass;
             $db = $this->db;
         }
     }
     $table = $this->tableFromQuery($sql);
     if (!in_array($table, $this->hotTable) && $this->enableCache) {
         $cache = new cache_class($table, '');
         $cache->delete();
     }
     $out = "ok";
     $q = NULL;
     $conn = mysql_connect($host, $user, $pass);
     if (!($conn == FALSE)) {
         if (!(mysql_select_db($db, $conn) == FALSE)) {
             mysql_query("SET NAMES 'utf8'");
             mysql_query($sql, $conn);
             if ($close) {
                 mysql_close($conn);
             } else {
                 $out = $conn;
             }
         } else {
             $out = "Select DB Error.";
         }
     } else {
         $out = "Connect MySql Error.";
     }
     return $out;
 }
Example #2
0
 public function directQueryx($sql)
 {
     /*
        $conf= new conf;
        $host = $conf->host;
        $db =$conf->db;
        $user = $conf->user;
        $pass = $conf->pass;
        if(isset($this) && get_class($this) == __CLASS__)
        {
                if(isset($this->ex_db) && $this->ex_db)
                {
                        $host = $this->host;
                        $user = $this->user;
                        $pass = $this->pass;
                        $db = $this->db;
                }
        }
     //			$db = $this->convertDB($sql);
        $out = "ok";
        $q = NULL;
     			$db = $this->convertDB($sql,$db);
     			$sql = $this->convertQuery(mysql_class::arabicToPersian($sql));
        $conn = mysql_connect($host,$user,$pass);
        if(!($conn==FALSE)){
                if(!(mysql_select_db($db,$conn)==FALSE)){
                        mysql_query("SET NAMES 'utf8'");
                        mysql_query($sql,$conn);
                        mysql_close($conn);
                }else
                        $out = "Select DB Error.";
        }else
                $out = "Connect MySql Error.";
     * 
     */
     $this->load->database();
     $sql = $this->convertQuery(mysql_class::arabicToPersian($sql));
     $this->db->query($sql);
     return $this->db->insert_id();
 }