$query = mysql_query(sprintf('SELECT * FROM `sse_data_table` WHERE `key` = \'%s\'', $this->escape($key)), $this->conn); $res = mysql_fetch_assoc($query); return $res['value']; } /* * @method SSEData_MySQL::set * @param $key the ID of the data * @param $value the data * @description add data to the table */ public function set($key, $value) { if ($this->get($key)) { return mysql_query(sprintf("UPDATE `sse_data_table` SET `value` = '%s' WHERE `key` = '%s'", $this->escape($value), $this->escape($key)), $this->conn); } else { return mysql_query(sprintf("INSERT INTO `sse_data_table` SET `key` = '%s', `value` = '%s'", $this->escape($key), $this->escape($value)), $this->conn); } } /* * @method SSEData_MySQL::delete * @param $key the ID of the data * @description delete the data with the same ID specified */ public function delete($key) { return mysql_query(sprintf('DELETE FROM `sse_data_table` WHERE `key` == \'%s\'', $this->escape($key)), $this->conn); } } //register the module SSEData::register('mysql', 'SSEData_MySQL');
* @param $key the ID of the data * @description delete the data with the same ID specified */ public function delete($key) { $path = $this->path . '/sess_' . sha1($key); if (file_exists($path)) { unlink($path); } return true; } /* * @method SSEData_File::gc * @description remove keys that are unused for a specified period */ private function gc() { if ($this->gc_lifetime === 0) { return; } foreach (glob($this->path . '/sess_*') as $file) { if (filemtime($file) + $this->gc_lifetime < time() && file_exists($file)) { unlink($file); } } return true; } } //register the module SSEData::register('file', 'SSEData_File');
$query = mysqli_query($this->conn, sprintf('SELECT * FROM `sse_data_table` WHERE `key` = \'%s\'', $this->escape($key))); $res = mysqli_fetch_assoc($query); return $res['value']; } /* * @method SSEData_MySQLi::set * @param $key the ID of the data * @param $value the data * @description add data to the table */ public function set($key, $value) { if ($this->get($key)) { return mysqli_query($this->conn, sprintf("UPDATE `sse_data_table` SET `value` = '%s' WHERE `key` = '%s'", $this->escape($value), $this->escape($key))); } else { return mysqli_query($this->conn, sprintf("INSERT INTO `sse_data_table` SET `key` = '%s', `value` = '%s'", $this->escape($key), $this->escape($value))); } } /* * @method SSEData_MySQLi::delete * @param $key the ID of the data * @description delete the data with the same ID specified */ public function delete($key) { return mysqli_query($this->conn, sprintf('DELETE FROM `sse_data_table` WHERE `key` == \'%s\'', $this->escape($key))); } } //register the module SSEData::register('mysqli', 'SSEData_MySQLi');
* @method SSEData_APC::get * @param $key the ID of the data * @description get the data by the key */ public function get($key) { return apc_fetch($key); } /* * @method SSEData_APC::set * @param $key the ID of the data * @param $value the data * @description add data to the cache */ public function set($key, $value) { return apc_store($key, $value); } /* * @method SSEData_APC::delete * @param $key the ID of the data * @description delete the data with the same ID specified */ public function delete($key) { return apc_delete($key); } } //register the module SSEData::register('apc', 'SSEData_APC');