本文整理汇总了PHP中ADODB_Session::expireNotify方法的典型用法代码示例。如果您正苦于以下问题:PHP ADODB_Session::expireNotify方法的具体用法?PHP ADODB_Session::expireNotify怎么用?PHP ADODB_Session::expireNotify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADODB_Session
的用法示例。
在下文中一共展示了ADODB_Session::expireNotify方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gc
function gc($maxlifetime)
{
$conn =& ADODB_Session::_conn();
$debug = ADODB_Session::debug();
$expire_notify = ADODB_Session::expireNotify();
$optimize = ADODB_Session::optimize();
$sync_seconds = ADODB_Session::syncSeconds();
$table = ADODB_Session::table();
if (!$conn) {
return false;
}
$time = time();
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
if ($expire_notify) {
reset($expire_notify);
$fn = next($expire_notify);
$savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
$sql = "SELECT expireref, sesskey FROM {$table} WHERE expiry < {$time}";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
$conn->SetFetchMode($savem);
if ($rs) {
$conn->StartTrans();
$keys = array();
while (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
$fn($ref, $key);
$del = $conn->Execute("DELETE FROM {$table} WHERE sesskey=" . $conn->Param('0'), array($key));
$rs->MoveNext();
}
$rs->Close();
$conn->CompleteTrans();
}
} else {
if (1) {
$sql = "SELECT sesskey FROM {$table} WHERE expiry < {$time}";
$arr =& $conn->GetAll($sql);
foreach ($arr as $row) {
$sql2 = "DELETE FROM {$table} WHERE sesskey=" . $conn->Param('0');
$conn->Execute($sql2, array($row[0]));
}
} else {
$sql = "DELETE FROM {$table} WHERE expiry < {$time}";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
if ($rs) {
$rs->Close();
}
}
if ($debug) {
ADOConnection::outp("<p><b>Garbage Collection</b>: {$sql}</p>");
}
}
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if ($optimize) {
$driver = ADODB_Session::driver();
if (preg_match('/mysql/i', $driver)) {
$sql = "OPTIMIZE TABLE {$table}";
}
if (preg_match('/postgres/i', $driver)) {
$sql = "VACUUM {$table}";
}
if (!empty($sql)) {
$conn->Execute($sql);
}
}
if ($sync_seconds) {
$sql = 'SELECT ';
if ($conn->dataProvider === 'oci8') {
$sql .= "TO_CHAR({$conn->sysTimeStamp}, 'RRRR-MM-DD HH24:MI:SS')";
} else {
$sql .= $conn->sysTimeStamp;
}
$sql .= " FROM {$table}";
$rs =& $conn->SelectLimit($sql, 1);
if ($rs && !$rs->EOF) {
$dbts = reset($rs->fields);
$rs->Close();
$dbt = $conn->UnixTimeStamp($dbts);
$t = time();
if (abs($dbt - $t) >= $sync_seconds) {
$msg = __FILE__ . ": Server time for webserver {$_SERVER['HTTP_HOST']} not in synch with database: " . " database={$dbt} ({$dbts}), webserver={$t} (diff=" . abs($dbt - $t) / 60 . ' minutes)';
error_log($msg);
if ($debug) {
ADOConnection::outp("<p>{$msg}</p>");
}
}
}
}
return true;
}
示例2: gc
static function gc($maxlifetime)
{
$conn = ADODB_Session::_conn();
$debug = ADODB_Session::debug();
$expire_notify = ADODB_Session::expireNotify();
$optimize = ADODB_Session::optimize();
$table = ADODB_Session::table();
if (!$conn) {
return false;
}
$debug = ADODB_Session::debug();
if ($debug) {
$conn->debug = 1;
$COMMITNUM = 2;
} else {
$COMMITNUM = 20;
}
//assert('$table');
$time = $conn->OffsetDate(-$maxlifetime / 24 / 3600, $conn->sysTimeStamp);
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
if ($expire_notify) {
reset($expire_notify);
$fn = next($expire_notify);
} else {
$fn = false;
}
$savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
$sql = "SELECT expireref, sesskey FROM {$table} WHERE expiry < {$time} ORDER BY 2";
# add order by to prevent deadlock
$rs = $conn->SelectLimit($sql, 1000);
if ($debug) {
ADODB_Session::_dumprs($rs);
}
$conn->SetFetchMode($savem);
if ($rs) {
$tr = $conn->hasTransactions;
if ($tr) {
$conn->BeginTrans();
}
$keys = array();
$ccnt = 0;
while (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
if ($fn) {
$fn($ref, $key);
}
$del = $conn->Execute("DELETE FROM {$table} WHERE sesskey=" . $conn->Param('0'), array($key));
$rs->MoveNext();
$ccnt += 1;
if ($tr && $ccnt % $COMMITNUM == 0) {
if ($debug) {
echo "Commit<br>\n";
}
$conn->CommitTrans();
$conn->BeginTrans();
}
}
$rs->Close();
if ($tr) {
$conn->CommitTrans();
}
}
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if ($optimize) {
$driver = ADODB_Session::driver();
if (preg_match('/mysql/i', $driver)) {
$sql = "OPTIMIZE TABLE {$table}";
}
if (preg_match('/postgres/i', $driver)) {
$sql = "VACUUM {$table}";
}
if (!empty($sql)) {
$conn->Execute($sql);
}
}
return true;
}
示例3: define
*
* @author Organisation: Queen's University
* @author Unit: School of Medicine
* @author Developer: Matt Simpson <matt.simpson@queensu.ca>
* @copyright Copyright 2010 Queen's University. All Rights Reserved.
*
*/
$ADODB_QUOTE_FIELDNAMES = true;
// Whether or not you want ADOdb to backtick field names in AutoExecute, GetInsertSQL and GetUpdateSQL.
define("ADODB_QUOTE_FIELDNAMES", $ADODB_QUOTE_FIELDNAMES);
// Information required to start a new database connection.
$db = NewADOConnection(DATABASE_TYPE);
$db->Connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);
$db->SetFetchMode(ADODB_FETCH_ASSOC);
if (defined("DEFAULT_CHARSET") && isset($ENTRADA_CHARSETS) && is_array($ENTRADA_CHARSETS) && array_key_exists(DEFAULT_CHARSET, $ENTRADA_CHARSETS)) {
$db->Execute("SET NAMES " . $db->qstr($ENTRADA_CHARSETS[DEFAULT_CHARSET]["mysql_names"]) . " COLLATE " . $db->qstr($ENTRADA_CHARSETS[DEFAULT_CHARSET]["mysql_collate"]));
}
$db->debug = isset($DEVELOPER_IPS) && is_array($DEVELOPER_IPS) && isset($_SERVER["REMOTE_ADDR"]) && in_array($_SERVER["REMOTE_ADDR"], $DEVELOPER_IPS) && isset($_GET["debug"]) ? true : false;
@ini_set("session.name", SESSION_NAME);
@ini_set("session.gc_maxlifetime", SESSION_EXPIRES);
if (defined("ADODB_SESSION") && defined("DATABASE_SESSIONS") && DATABASE_SESSIONS) {
require_once "Entrada/adodb/session/adodb-session2.php";
ADODB_Session::config(SESSION_DATABASE_TYPE, SESSION_DATABASE_HOST, SESSION_DATABASE_USER, SESSION_DATABASE_PASS, SESSION_DATABASE_NAME, array("table" => "sessions"));
ADODB_Session::encryptionKey(ENCRYPTION_KEY);
ADODB_Session::open(false, false, false);
ADODB_Session::optimize(true);
ADODB_Session::expireNotify(array("PROXY_ID", "expired_session"));
session_start();
} else {
session_start();
}
示例4: gc
function gc($maxlifetime)
{
$conn =& ADODB_Session::_conn();
$debug = ADODB_Session::debug();
$expire_notify = ADODB_Session::expireNotify();
$optimize = ADODB_Session::optimize();
$table = ADODB_Session::table();
if (!$conn) {
return false;
}
//assert('$table');
$time = $conn->sysTimeStamp;
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
if ($expire_notify) {
reset($expire_notify);
$fn = next($expire_notify);
$savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
$sql = "SELECT expireref, sesskey FROM {$table} WHERE expiry < {$time}";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
$conn->SetFetchMode($savem);
if ($rs) {
$conn->StartTrans();
$keys = array();
while (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
$fn($ref, $key);
$del = $conn->Execute("DELETE FROM {$table} WHERE sesskey=" . $conn->Param('0'), array($key));
$rs->MoveNext();
}
$rs->Close();
$conn->CompleteTrans();
}
} else {
if (0) {
$sql = "SELECT sesskey FROM {$table} WHERE expiry < {$time}";
$arr =& $conn->GetAll($sql);
foreach ($arr as $row) {
$sql2 = "DELETE FROM {$table} WHERE sesskey=" . $conn->Param('0');
$conn->Execute($sql2, array(reset($row)));
}
} else {
$sql = "DELETE FROM {$table} WHERE expiry < {$time}";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
if ($rs) {
$rs->Close();
}
}
if ($debug) {
ADOConnection::outp("<p><b>Garbage Collection</b>: {$sql}</p>");
}
}
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if ($optimize) {
$driver = ADODB_Session::driver();
if (preg_match('/mysql/i', $driver)) {
$sql = "OPTIMIZE TABLE {$table}";
}
if (preg_match('/postgres/i', $driver)) {
$sql = "VACUUM {$table}";
}
if (!empty($sql)) {
$conn->Execute($sql);
}
}
return true;
}
示例5: NotifyFn
ADODB_Session::host($host);
ADODB_Session::lifetime($lifetime);
ADODB_Session::optimize($optimize);
ADODB_Session::password($password);
ADODB_Session::syncSeconds($sync_seconds);
ADODB_Session::table($table);
ADODB_Session::user($user);
}
function NotifyFn($var, $sesskey)
{
echo "NotifyFn({$var}, {$sesskey}) called<br />\n";
}
if ($expire_notify) {
$ADODB_SESSION_EXPIRE_NOTIFY = array('debug', 'NotifyFn');
if (class_exists('ADODB_Session')) {
ADODB_Session::expireNotify(array('debug', 'NotifyFn'));
}
}
session_start();
$register = true;
if (!empty($_REQUEST['submit'])) {
switch ($_REQUEST['submit']) {
case 'Change Driver':
case 'Delete Session':
$_SESSION = array();
setcookie(session_name(), '', time() - 2592000, '/', '', 0);
session_destroy();
$register = false;
break;
default:
}