本文整理汇总了PHP中dba_firstkey函数的典型用法代码示例。如果您正苦于以下问题:PHP dba_firstkey函数的具体用法?PHP dba_firstkey怎么用?PHP dba_firstkey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dba_firstkey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset
function reset()
{
if (!$this->obj->db) {
return;
}
$this->key = dba_firstkey($this->obj->db);
}
示例2: dba_fetch_assoc
function dba_fetch_assoc($handle)
{
$assoc = array();
for ($k = dba_firstkey($handle); $k != false; $k = dba_nextkey($handle)) {
$assoc[$k] = dba_fetch($k, $handle);
echo "\$k: {$k}, \$assoc[\$k]: " . $assoc[$k] . "\n";
}
return $assoc;
}
示例3: hasNext
/**
* Returns true if the iteration has more elements. (In other words,
* returns true if next would return an element rather than throwing
* an exception.)
*
* @return bool
*/
public function hasNext()
{
if (NULL === $this->_key) {
// First call
$this->_key = dba_firstkey($this->_fd);
} else {
// Subsequent calls
$this->_key = dba_nextkey($this->_fd);
}
return is_string($this->_key);
}
示例4: process
/**
* Internal cleaning process.
*
* @param boolean $cleanAll
*
* @return void
*/
protected function process($cleanAll = true)
{
$key = dba_firstkey($this->cache->getDba());
while ($key !== false && $key !== null) {
if (true === $cleanAll) {
$this->cache->delete($key);
} else {
$this->cache->get($key);
}
$key = dba_nextkey($this->cache->getDba());
}
dba_optimize($this->cache->getDba());
}
示例5: getKeys
public function getKeys()
{
$db = dba_open($this->filePath, 'wl', 'db4');
$key = dba_firstkey($db);
$keys_array = array();
while ($key != false) {
if (true) {
// remember the key to perform some action later
$keys_array[] = $key;
}
$key = dba_nextkey($db);
}
dba_close($db);
return $keys_array;
}
示例6: size
/**
* Calculates the size of the database in number of keys
*
* @access public
* @return int number of keys in the database
*/
function size()
{
$key = dba_firstkey($this->_dba);
$size = 0;
while ($key !== false) {
++$size;
$key = dba_nextkey($this->_dba);
}
return $size;
}
示例7: dirname
<?php
$handler = 'cdb';
require_once dirname(__FILE__) . '/test.inc';
echo "Test 0\n";
if (($db_file = dba_open($db_filename, 'n', $handler)) !== FALSE) {
var_dump(dba_insert("key1", "Content String 1", $db_file));
var_dump(dba_replace("key1", "New Content String", $db_file));
var_dump(dba_fetch("key1", $db_file));
var_dump(dba_firstkey($db_file));
var_dump(dba_delete("key1", $db_file));
var_dump(dba_optimize($db_file));
var_dump(dba_sync($db_file));
dba_close($db_file);
} else {
echo "Failed to open DB\n";
}
unlink($db_filename);
echo "Test 1\n";
if (($db_file = dba_open($db_filename, 'c', $handler)) !== FALSE) {
dba_insert("key1", "Content String 1", $db_file);
dba_close($db_file);
} else {
echo "Failed to open DB\n";
}
echo "Test 2\n";
if (($db_file = dba_open($db_filename, 'r', $handler)) !== FALSE) {
dba_insert("key1", "Content String 1", $db_file);
dba_close($db_file);
} else {
echo "Failed to open DB\n";
示例8: ALLFILES
function ALLFILES()
{
$id = dba_firstkey($this->handle);
while ($id != false) {
$p = strrpos($id, ".");
$id = substr($id, 0, $p);
$r[$id] = $id;
$id = dba_nextkey($this->handle);
}
$r = array_values($r);
return $r;
}
示例9: keys
/**
* Returns an array of keys
*
* Note: Do not use this for databases containing large amounts
* of keys, use the iterator() method instead.
*
* @return string[] keys
* @throws io.IOException in case fetching the keys fails
* @see xp://io.dba.DBAFile#iterator
*/
public function keys()
{
$keys = array();
if (NULL === ($k = dba_firstkey($this->_fd))) {
throw new IOException('Could not fetch first key');
}
while (is_string($k)) {
$keys[] = $k;
$k = dba_nextkey($this->_fd);
}
return $keys;
}
示例10: firstkey
function firstkey()
{
return dba_firstkey($this->_dbh);
}
示例11: HyperCacheSizeLog
function HyperCacheSizeLog($dbfile)
{
$dbfile = "/usr/share/squid3/HyperCacheSizeLog.db";
if (!is_file($dbfile)) {
return;
}
$db_con = dba_open($path, "r", "db4");
if (!$db_con) {
return false;
}
$mainkey = dba_firstkey($db_con);
while ($mainkey != false) {
$val = 0;
$array = unserialize(dba_fetch($mainkey, $db_con));
$zDate = $mainkey;
$mainkey = dba_nextkey($db_con);
if (!is_array($data)) {
continue;
}
}
dba_close($db_con);
$this->ok = true;
return $wwwUH;
}
示例12: getAll
public function getAll()
{
// reset cache
$this->cache = [];
$tmp = [];
// read all
for ($key = dba_firstkey($this->dbHandler); $key != false; $key = dba_nextkey($this->dbHandler)) {
$v = dba_fetch($key, $this->dbHandler);
// Convert
$value = $this->decode($v);
// Store
$tmp[$key] = $value;
}
if ($this->useCache) {
$this->cache = $tmp;
}
return $tmp;
}
示例13: define
<?php
// xxx
// dump the dict.cdb to dict.txt
//
define("_WORD_ALONE_", 0x4000000);
define("_WORD_PART_", 0x8000000);
$db = dba_open("dict.cdb", "r", "cdb");
$total = 0;
if ($key = dba_firstkey($db)) {
do {
$value = (int) dba_fetch($key, $db);
if (!($value & _WORD_ALONE_)) {
continue;
}
$value &= ~(_WORD_ALONE_ | _WORD_PART_);
echo "{$key}\t\t{$value}\r\n";
$total++;
} while ($key = dba_nextkey($db));
}
dba_close($db);
echo "# total {$total}\n";
示例14: firstkey
/**
* Retrieves the first key in the database.
*
* @access public
* @return string
*
*/
function firstkey()
{
return @dba_firstkey($this->connection);
}
示例15: find_md5_loop
function find_md5_loop($filemd5)
{
$dbfile = "{$GLOBALS["HyperCacheStoragePath"]}/cache.db";
$db_con = @dba_open($dbfile, "r", "db4");
if (!$db_con) {
events("analyze:: FATAL!!!::{$dbfile}, unable to open");
return null;
}
$mainkey = dba_firstkey($db_con);
while ($mainkey != false) {
$array = unserialize(dba_fetch($mainkey, $db_con));
$keymd5 = $array["md5file"];
if ($keymd5 == $filemd5) {
$uri = $mainkey;
@dba_close($db_con);
return $uri;
}
$mainkey = dba_nextkey($db_con);
}
@dba_close($db_con);
}