Example #1
0
 public function select($sql, $skipModifiedMark = false)
 {
     if ($this->_rw_lnk) {
         $db_lnk =& $this->_rw_lnk;
     } else {
         if ($this->_ro_lnk) {
             $db_lnk =& $this->_ro_lnk;
         } else {
             $db_lnk =& $this->_ro_conn();
         }
     }
     if ($this->prefix != 'sdb_') {
         //$sql = preg_replace('/([`\s\(,])(sdb_)([a-z\_]+)([`\s\.]{0,1})/is',"\${1}".$this->prefix."\\3\\4",$sql);
         $sql = preg_replace_callback('/([`\\s\\(,])(sdb_)([0-9a-z\\_]+)([`\\s\\.]{0,1})/is', array($this, 'fix_dbprefix'), $sql);
         //todo: 兼容有特殊符号的表名前缀
     }
     //todo:为了配合check_expries判断表名,冗余执行
     if (cachemgr::enable() && cachemgr::check_current_co_depth() > 0 && preg_match('/FROM\\s+([]0-9a-z_:"`.@[-]*)/is', $sql, $matchs)) {
         if (isset($matchs[1])) {
             $table = strtoupper(trim(str_replace(array('`', '"', '\''), array('', '', ''), $matchs[1])));
             $pos = strpos($table, strtoupper($this->prefix));
             if ($pos === 0) {
                 $table = substr($table, strlen($this->prefix));
             }
             //todo: 真实表名
             if (!cachemgr::check_current_co_objects_exists('DB', $table)) {
                 cachemgr::check_expires('DB', $table);
             }
         }
     }
     $rs = $this->exec($sql, $skipModifiedMark, $db_lnk);
     if ($rs['rs']) {
         $data = array();
         while ($row = mysql_fetch_assoc($rs['rs'])) {
             $data[] = $row;
         }
         mysql_free_result($rs['rs']);
         return $data;
     } else {
         return false;
     }
 }
Example #2
0
File: mysql.php Project: noikiy/snk
 public function select($sql, $skipModifiedMark = false)
 {
     if ($this->_ro_lnk) {
         $db_lnk = $this->_ro_lnk;
     } else {
         $db_lnk = $this->_ro_conn();
     }
     if ($this->prefix != 'vmc_') {
         $sql = preg_replace_callback('/([`\\s\\(,])(vmc_)([0-9a-z\\_]+)([`\\s\\.]{0,1})/is', array($this, 'fix_dbprefix'), $sql);
     }
     if (cachemgr::enable() && cachemgr::check_current_co_depth() > 0 && preg_match_all('/FROM\\s+([]0-9a-z_:"`.@[-]*)/is', $sql, $matchs)) {
         if (isset($matchs[1])) {
             foreach ($matchs[1] as $table) {
                 if (empty($table)) {
                     continue;
                 }
                 $table = strtoupper(trim(str_replace(array('`', '"', '\''), array('', '', ''), $table)));
                 $pos = strpos($table, strtoupper($this->prefix));
                 if ($pos === 0) {
                     $table = substr($table, strlen($this->prefix));
                 }
                 //todo: 真实表名
                 if (!cachemgr::check_current_co_objects_exists('DB', $table)) {
                     cachemgr::check_expires('DB', $table);
                 }
             }
         }
     }
     $rs = $this->exec($sql, $skipModifiedMark, $db_lnk);
     if (!empty($rs['rs'])) {
         return $rs['rs'];
     } else {
         return false;
     }
 }
Example #3
0
 public function check_expires($key, $force = false)
 {
     if ($force || cachemgr::enable() && cachemgr::check_current_co_depth() > 0) {
         if (!isset($this->__checkVaryArr[$key])) {
             $this->__checkVaryArr[$key] = strtoupper(md5($this->app_id . $key));
         }
         if (!cachemgr::check_current_co_objects_exists('CONF', $this->__checkVaryArr[$key])) {
             cachemgr::check_expires('CONF', $this->__checkVaryArr[$key]);
         }
     }
 }