con = $con; $this->table = $table; } function _open($path,$name) { return true; } function _close() { $this->_gc(); return true; } function _read($ses_id) { $strReq = 'SELECT * FROM '.$this->table.' '. 'WHERE ses_id = \''.$ses_id.'\' '; $rs = $this->con->select($strReq); if ($rs->isEmpty()) { return ''; } else { return $rs->f('ses_value'); } } function _write($ses_id, $data) { $strReq = 'UPDATE '.$this->table.' SET '. 'ses_time = \''.time().'\', '. 'ses_value = \''.$data.'\' '. 'WHERE ses_id = \''.$ses_id.'\' '; if ($this->con->execute($strReq) === false) { return false; } if ($this->con->rowCount() > 0) { return true; } $strReq = 'INSERT INTO '.$this->table.' '. ' (ses_id, ses_time, ses_start, ses_value) VALUES ('. '\''.$ses_id.'\','. '\''.time().'\','. '\''.time().'\','. '\''.$data.'\') '; if ($this->con->execute($strReq) === false) { return false; } return true; } function _destroy($ses_id) { $strReq = 'DELETE FROM '.$this->table.' '. 'WHERE ses_id = \''.$ses_id.'\' '; if ($this->con->execute($strReq) === false) { return false; } else { $this->_optimize(); return true; } } function _gc() { $ses_life = strtotime($this->sess_ttl); $strReq = 'DELETE FROM '.$this->table.' '. 'WHERE ses_time < '.$ses_life.' '; if ($this->con->execute($strReq) === false) { return false; } if ($this->con->rowCount() > 0) { $this->_optimize(); } return true; } function _optimize() { $strReq = 'OPTIMIZE TABLE '.$this->table.' '; if ($this->con->execute($strReq) === false) { return false; } else { return true; } } } ?>