/** * 获取数据库中有多少条记录 * * @param string $sql SQL语句 * @return integer 数据记录数 */ private function _amount($sql) { if (stripos($sql, 'GROUP BY') !== false) { $this->_db->query($sql); $row_nu = $this->_db->num_rows(); } else { $res = $this->_db->fetch_row($sql); $row_nu = $res['CNUM']; } $this->_db->free(); $this->amount = $row_nu; return $this->amount; }
/** * 定时去清除过期的SESSION * * @param integer $max_life_time * @return boolean */ public function gc($max_life_time) { if ($this->_type == 'db' || $this->_type == 'mdb') { $this->_db->query("DELETE FROM {$this->_opt} WHERE sExpires < " . time()); } else { if ($this->_type == 'file') { self::kill_sfile($this->_path); } else { if ($this->_type == 'dir') { $dir = 'abcdefghijklmnopqrstuvwxyz'; $len = strlen($dir); for ($i = 0; $i < $len; ++$i) { self::kill_sfile("{$this->_path}/{$dir[$i]}"); } } } } return true; }