本文整理汇总了PHP中_rs2serialize函数的典型用法代码示例。如果您正苦于以下问题:PHP _rs2serialize函数的具体用法?PHP _rs2serialize怎么用?PHP _rs2serialize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_rs2serialize函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: err
$remote = $_SERVER["REMOTE_ADDR"];
if (!empty($ACCEPTIP)) {
if ($remote != '127.0.0.1' && $remote != $ACCEPTIP) {
err("Unauthorised client: '{$remote}'");
}
}
if (empty($_REQUEST['sql'])) {
err('No SQL');
}
$conn =& ADONewConnection($driver);
if (!$conn->Connect($host, $uid, $pwd, $database)) {
err($conn->ErrorNo() . $sep . $conn->ErrorMsg());
}
$sql = undomq($_REQUEST['sql']);
if (isset($_REQUEST['fetch'])) {
$ADODB_FETCH_MODE = $_REQUEST['fetch'];
}
if (isset($_REQUEST['nrows'])) {
$nrows = $_REQUEST['nrows'];
$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1;
$rs = $conn->SelectLimit($sql, $nrows, $offset);
} else {
$rs = $conn->Execute($sql);
}
if ($rs) {
//$rs->timeToLive = 1;
echo _rs2serialize($rs, $conn, $sql);
$rs->Close();
} else {
err($conn->ErrorNo() . $sep . $conn->ErrorMsg());
}
示例2: serialize
/**
* Execute SQL, caching recordsets.
*
* @param [secs2cache] seconds to cache data, set to 0 to force query.
* This is an optional parameter.
* @param sql SQL statement to execute
* @param [inputarr] holds the input data to bind to
* @return RecordSet or false
*/
function &CacheExecute($secs2cache, $sql = false, $inputarr = false)
{
global $ADODB_CACHE;
if (!is_numeric($secs2cache)) {
$inputarr = $sql;
$sql = $secs2cache;
$secs2cache = $this->cacheSecs;
}
if (is_array($sql)) {
$sqlparam = $sql;
$sql = $sql[0];
} else {
$sqlparam = $sql;
}
$md5file = $this->_gencachename($sql . serialize($inputarr), true);
$err = '';
if ($secs2cache > 0) {
$rs =& $ADODB_CACHE->readcache($md5file, $err, $secs2cache, $this->arrayClass);
$this->numCacheHits += 1;
} else {
$err = 'Timeout 1';
$rs = false;
$this->numCacheMisses += 1;
}
if (!$rs) {
// no cached rs found
if ($this->debug) {
if (get_magic_quotes_runtime() && !$this->memCache) {
ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
}
if ($this->debug !== -1) {
ADOConnection::outp(" {$md5file} cache failure: {$err} (see sql below)");
}
}
$rs =& $this->Execute($sqlparam, $inputarr);
if ($rs) {
$eof = $rs->EOF;
$rs =& $this->_rs2rs($rs);
// read entire recordset into memory immediately
$rs->timeCreated = time();
// used by caching
$txt = _rs2serialize($rs, false, $sql);
// serialize
$ok = $ADODB_CACHE->writecache($md5file, $txt, $this->debug, $secs2cache);
if (!$ok) {
if ($ok === false) {
$em = 'Cache write error';
$en = -32000;
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType, 'CacheExecute', $en, $em, $md5file, $sql, $this);
}
} else {
$em = 'Cache file locked warning';
$en = -32001;
// do not call error handling for just a warning
}
if ($this->debug) {
ADOConnection::outp(" " . $em);
}
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
//$rs = &csv2rs($md5file,$err);
$rs->connection =& $this;
// Pablo suggestion
}
} else {
if (!$this->memCache) {
$ADODB_CACHE->flushcache($md5file);
}
}
} else {
$this->_errorMsg = '';
$this->_errorCode = 0;
if ($this->fnCacheExecute) {
$fn = $this->fnCacheExecute;
$fn($this, $secs2cache, $sql, $inputarr);
}
// ok, set cached object found
$rs->connection =& $this;
// Pablo suggestion
if ($this->debug) {
$inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
$ttl = $rs->timeCreated + $secs2cache - time();
$s = is_array($sql) ? $sql[0] : $sql;
if ($inBrowser) {
$s = '<i>' . htmlspecialchars($s) . '</i>';
}
ADOConnection::outp(" {$md5file} reloaded, ttl={$ttl} [ {$s} ]");
}
}
//.........这里部分代码省略.........
示例3: CacheExecute
/**
* Execute SQL, caching recordsets.
*
* @param [secs2cache] seconds to cache data, set to 0 to force query.
* This is an optional parameter.
* @param sql SQL statement to execute
* @param [inputarr] holds the input data to bind to
* @return RecordSet or false
*/
function CacheExecute($secs2cache, $sql = false, $inputarr = false)
{
if (!is_numeric($secs2cache)) {
$inputarr = $sql;
$sql = $secs2cache;
$secs2cache = $this->cacheSecs;
}
if (is_array($sql)) {
$sqlparam = $sql;
$sql = $sql[0];
} else {
$sqlparam = $sql;
}
if ($this->memCache) {
global $ADODB_INCLUDED_MEMCACHE;
if (empty($ADODB_INCLUDED_MEMCACHE)) {
include ADODB_DIR . '/adodb-memcache.lib.inc.php';
}
$md5file = $this->_gencachename($sql . serialize($inputarr), false, true);
} else {
global $ADODB_INCLUDED_CSV;
if (empty($ADODB_INCLUDED_CSV)) {
include ADODB_DIR . '/adodb-csvlib.inc.php';
}
$md5file = $this->_gencachename($sql . serialize($inputarr), true);
}
$err = '';
if ($secs2cache > 0) {
if ($this->memCache) {
$rs = getmemCache($md5file, $err, $secs2cache, $this->memCacheHost, $this->memCachePort);
} else {
$rs = csv2rs($md5file, $err, $secs2cache, $this->arrayClass);
}
$this->numCacheHits += 1;
} else {
$err = 'Timeout 1';
$rs = false;
$this->numCacheMisses += 1;
}
if (!$rs) {
// no cached rs found
if ($this->debug) {
if (get_magic_quotes_runtime() && !$this->memCache) {
ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
}
if ($this->debug !== -1) {
ADOConnection::outp(" {$md5file} cache failure: {$err} (see sql below)");
}
}
$rs = $this->Execute($sqlparam, $inputarr);
if ($rs && $this->memCache) {
$rs = $this->_rs2rs($rs);
// read entire recordset into memory immediately
if (!putmemCache($md5file, $rs, $this->memCacheHost, $this->memCachePort, $this->memCacheCompress, $this->debug)) {
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType, 'CacheExecute', -32000, "Cache write error", $md5file, $sql, $this);
}
if ($this->debug) {
ADOConnection::outp(" Cache write error");
}
}
} else {
if ($rs) {
$eof = $rs->EOF;
$rs = $this->_rs2rs($rs);
// read entire recordset into memory immediately
$txt = _rs2serialize($rs, false, $sql);
// serialize
if (!adodb_write_file($md5file, $txt, $this->debug)) {
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType, 'CacheExecute', -32000, "Cache write error", $md5file, $sql, $this);
}
if ($this->debug) {
ADOConnection::outp(" Cache write error");
}
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
//$rs = csv2rs($md5file,$err);
$rs->connection = $this;
// Pablo suggestion
}
} else {
if (!$this->memCache) {
@unlink($md5file);
}
}
}
} else {
$this->_errorMsg = '';
$this->_errorCode = 0;
//.........这里部分代码省略.........
示例4: _rs2serialize
/**
* Execute SQL, caching recordsets.
*
* @param [secs2cache] seconds to cache data, set to 0 to force query.
* This is an optional parameter.
* @param sql SQL statement to execute
* @param [inputarr] holds the input data to bind to
* @return RecordSet or false
*/
function &CacheExecute($secs2cache,$sql=false,$inputarr=false)
{
if (!is_numeric($secs2cache)) {
$inputarr = $sql;
$sql = $secs2cache;
$secs2cache = $this->cacheSecs;
}
global $ADODB_INCLUDED_CSV;
if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
if (is_array($sql)) $sql = $sql[0];
$md5file = $this->_gencachename($sql.serialize($inputarr),true);
$err = '';
if ($secs2cache > 0){
$rs = &csv2rs($md5file,$err,$secs2cache);
$this->numCacheHits += 1;
} else {
$err='Timeout 1';
$rs = false;
$this->numCacheMisses += 1;
}
if (!$rs) {
// no cached rs found
if ($this->debug) {
if (get_magic_quotes_runtime()) {
ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
}
if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
}
$rs = &$this->Execute($sql,$inputarr);
if ($rs) {
$eof = $rs->EOF;
$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
$txt = _rs2serialize($rs,false,$sql); // serialize
if (!adodb_write_file($md5file,$txt,$this->debug)) {
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this);
}
if ($this->debug) ADOConnection::outp( " Cache write error");
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
//$rs = &csv2rs($md5file,$err);
$rs->connection = &$this; // Pablo suggestion
}
} else
@unlink($md5file);
} else {
$this->_errorMsg = '';
$this->_errorCode = 0;
if ($this->fnCacheExecute) {
$fn = $this->fnCacheExecute;
$fn($this, $secs2cache, $sql, $inputarr);
}
// ok, set cached object found
$rs->connection = &$this; // Pablo suggestion
if ($this->debug){
global $HTTP_SERVER_VARS;
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
$ttl = $rs->timeCreated + $secs2cache - time();
$s = is_array($sql) ? $sql[0] : $sql;
if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>';
ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]");
}
}
return $rs;
}
示例5: serialize
/**
* Execute SQL, caching recordsets.
*
* @param [secs2cache] seconds to cache data, set to 0 to force query.
* This is an optional parameter.
* @param sql SQL statement to execute
* @param [inputarr] holds the input data to bind to
* @param [arg3] reserved for john lim for future use
* @return RecordSet or false
*/
function &CacheExecute($secs2cache, $sql = false, $inputarr = false, $arg3 = false)
{
if (!is_numeric($secs2cache)) {
$arg3 = $inputarr;
$inputarr = $sql;
$sql = $secs2cache;
$secs2cache = $this->cacheSecs;
}
include_once ADODB_DIR . '/adodb-csvlib.inc.php';
$md5file = $this->_gencachename($sql . serialize($inputarr), true);
$err = '';
if ($secs2cache > 0) {
$rs =& csv2rs($md5file, $err, $secs2cache);
$this->numCacheHits += 1;
} else {
$err = 'Timeout 1';
$rs = false;
$this->numCacheMisses += 1;
}
if (!$rs) {
/* no cached rs found */
if ($this->debug) {
if (get_magic_quotes_runtime()) {
ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
}
ADOConnection::outp(" {$md5file} cache failure: {$err} (see sql below)");
}
$rs =& $this->Execute($sql, $inputarr, $arg3);
if ($rs) {
$eof = $rs->EOF;
$rs =& $this->_rs2rs($rs);
/* read entire recordset into memory immediately */
$txt = _rs2serialize($rs, false, $sql);
/* serialize */
if (!adodb_write_file($md5file, $txt, $this->debug)) {
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType, 'CacheExecute', -32000, "Cache write error", $md5file, $sql, $this);
}
if ($this->debug) {
ADOConnection::outp(" Cache write error");
}
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
/* $rs = &csv2rs($md5file,$err); */
$rs->connection =& $this;
/* Pablo suggestion */
}
} else {
@unlink($md5file);
}
} else {
if ($this->fnCacheExecute) {
$fn = $this->fnCacheExecute;
$fn($this, $secs2cache, $sql, $inputarr);
}
/* ok, set cached object found */
$rs->connection =& $this;
/* Pablo suggestion */
if ($this->debug) {
global $HTTP_SERVER_VARS;
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
$ttl = $rs->timeCreated + $secs2cache - time();
$s = is_array($sql) ? $sql[0] : $sql;
if ($inBrowser) {
$s = '<i>' . htmlspecialchars($s) . '</i>';
}
ADOConnection::outp(" {$md5file} reloaded, ttl={$ttl} [ {$s} ]");
}
}
return $rs;
}