当前位置: 首页>>代码示例>>PHP>>正文


PHP dba_popen函数代码示例

本文整理汇总了PHP中dba_popen函数的典型用法代码示例。如果您正苦于以下问题:PHP dba_popen函数的具体用法?PHP dba_popen怎么用?PHP dba_popen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dba_popen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct($prefix)
 {
     if (!is_dir(DATA_DIR . '/kvstore/')) {
         utils::mkdir_p(DATA_DIR . '/kvstore/');
     }
     $this->rs = dba_popen(DATA_DIR . '/kvstore/dba.db', 'c');
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:7,代码来源:dba.php

示例2: get_db_handle

 private function get_db_handle($mode)
 {
     if (!isset($this->db_handles[$mode])) {
         $fn = self::get_db_file_name();
         $h = self::get_db_handler();
         $this->db_handles[$mode] = dba_popen($fn, $h, $mode);
     }
     return $this->db_handles[$mode];
 }
开发者ID:saulhoward,项目名称:haddock-cms,代码行数:9,代码来源:HaddockProjectOrganisation_ConfigDBManager.inc.php

示例3: __construct

 /**
  * @param string  $file    the cache-file.
  *
  * @param string  $handler the dba handler.
  *
  * You have to install one of this handlers before use.
  *
  * cdb      = Tiny Constant Database - for reading.
  * cdb_make = Tiny Constant Database - for writing.
  * db4      = Oracle Berkeley DB 4   - for reading and writing.
  * qdbm     = Quick Database Manager - for reading and writing.
  * gdbm     = GNU Database Manager   - for reading and writing.
  * flatfile = default dba extension  - for reading and writing.
  *
  * Use flatfile-handler only when you cannot install one,
  * of the libraries required by the other handlers,
  * and when you cannot use bundled cdb handler.
  *
  * @param string  $mode    For read/write access, database creation if it doesn't currently exist.
  *
  * @param boolean $persistently
  *
  * @throws \RuntimeException If no DBA extension or handler installed.
  */
 public function __construct($file, $handler = 'flatfile', $mode = 'c', $persistently = true)
 {
     if (false === extension_loaded('dba')) {
         throw new \RuntimeException('The DBA extension is required for this wrapper, but the extension is not loaded');
     }
     if (false === in_array($handler, dba_handlers(false))) {
         throw new \RuntimeException('The ' . $handler . ' handler is required for the DBA extension, but the handler is not installed');
     }
     $this->dba = true === $persistently ? dba_popen($file, $mode, $handler) : dba_open($file, $mode, $handler);
     $this->file = $file;
     $this->handler = $handler;
 }
开发者ID:gjerokrsteski,项目名称:pimf-framework,代码行数:36,代码来源:Dba.php

示例4: __construct

 /**
  * @param string  $file    the cache-file.
  *
  * @param string  $handler the dba handler.
  *
  * You have to install one of this handlers before use.
  *
  * cdb      = Tiny Constant Database - for reading.
  * cdb_make = Tiny Constant Database - for writing.
  * db4      = Oracle Berkeley DB 4   - for reading and writing.
  * qdbm     = Quick Database Manager - for reading and writing.
  * gdbm     = GNU Database Manager   - for reading and writing.
  * inifile  = Ini File               - for reading and writing.
  * flatfile = default dba extension  - for reading and writing.
  *
  * Use "flatfile" only when you cannot install one, of the libraries
  * required by the other handlers, and when you cannot use bundled cdb handler.
  *
  * @param string  $mode    For read/write access, database creation if it doesn't currently exist.
  *
  * r  = for read access
  * w  = for read/write access to an already existing database
  * c  = for read/write access and database creation if it doesn't currently exist
  * n  = for create, truncate and read/write access
  *
  * When you are absolutely sure that you do not require database locking you can use "-" as suffix.
  *
  * @param boolean $persistently
  *
  * @throws \RuntimeException If no DBA extension or handler installed.
  */
 public function __construct($file, $handler = 'flatfile', $mode = 'c', $persistently = true)
 {
     if (!extension_loaded('dba')) {
         throw new \RuntimeException('missing ext/dba');
     }
     if (!function_exists('dba_handlers') || !in_array($handler, dba_handlers(false))) {
         throw new \RuntimeException("dba-handler '{$handler}' not supported");
     }
     $this->dba = true === $persistently ? @dba_popen($file, $mode, $handler) : @dba_open($file, $mode, $handler);
     if ($this->dba === false) {
         $err = error_get_last();
         throw new \RuntimeException($err['message']);
     }
     $this->storage = $file;
     $this->handler = $handler;
 }
开发者ID:gjerokrsteski,项目名称:php-dba-cache,代码行数:47,代码来源:Cache.php

示例5: _handler

 protected function _handler($mode = 'r')
 {
     $handler = '_' . $mode . 'Handler';
     if (null === $this->{$handler}) {
         switch ($mode) {
             case 'r':
                 $this->_rHandler = dba_popen($this->_options['dba_file'], 'r', $this->_options['dba_type']);
                 break;
             case 'w':
                 $this->_wHandler = dba_open($this->_options['dba_file'], 'c', $this->_options['dba_type']);
                 $this->_rHandler = $this->_wHandler;
                 break;
             default:
                 throw new Exception('Not support mode, mode must be r or w.');
         }
     }
     return $this->{$handler};
 }
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:18,代码来源:Dba.php

示例6: dirname

<?php

$handler = "flatfile";
require_once dirname(__FILE__) . '/test.inc';
echo "database handler: {$handler}\n";
$db_file1 = dba_popen($db_filename, 'n-t', 'flatfile');
?>
===DONE===
开发者ID:gleamingthecube,项目名称:php,代码行数:8,代码来源:ext_dba_tests_dba016.php

示例7: patchworkPath

function patchworkPath($file, &$last_level = false, $level = false, $base = false)
{
    if (false === $level) {
        /**/
        if ('\\' === DIRECTORY_SEPARATOR) {
            if (isset($file[0]) && ('\\' === $file[0] || false !== strpos($file, ':'))) {
                return $file;
            }
        }
        if (isset($file[0]) && '/' === $file[0]) {
            return $file;
        }
        $i = 0;
        $level = PATCHWORK_PATH_LEVEL;
    } else {
        0 <= $level && ($base = 0);
        $i = PATCHWORK_PATH_LEVEL - $level - $base;
        0 > $i && ($i = 0);
    }
    /**/
    if ('\\' === DIRECTORY_SEPARATOR) {
        false !== strpos($file, '\\') && ($file = strtr($file, '\\', '/'));
    }
    if (0 === $i) {
        $source = PATCHWORK_PROJECT_PATH . $file;
        if (file_exists($source)) {
            $last_level = $level;
            /**/
            if ('\\' === DIRECTORY_SEPARATOR) {
                return false !== strpos($source, '/') ? strtr($source, '/', '\\') : $source;
            } else {
                return $source;
            }
        }
    }
    if ($slash = '/' === substr($file, -1)) {
        $file = substr($file, 0, -1);
    }
    /**/
    require boot::$manager->getCurrentDir() . 'class/Patchwork/Updatedb.php';
    /**/
    $a = new Patchwork\Updatedb();
    /**/
    $a = $a->buildPathCache($GLOBALS['patchwork_path'], PATCHWORK_PATH_LEVEL, PATCHWORK_PROJECT_PATH, PATCHWORK_ZCACHE);
    /**/
    if ($a) {
        static $db;
        if (!isset($db)) {
            if (!($db = @dba_popen(PATCHWORK_PROJECT_PATH . '.patchwork.paths.db', 'rd', $a))) {
                require boot::$manager->getCurrentDir() . 'class/Patchwork/Updatedb.php';
                $db = new Patchwork\Updatedb();
                $db->buildPathCache($GLOBALS['patchwork_path'], PATCHWORK_PATH_LEVEL, PATCHWORK_PROJECT_PATH, PATCHWORK_ZCACHE);
                if (!($db = dba_popen(PATCHWORK_PROJECT_PATH . '.patchwork.paths.db', 'rd', $a))) {
                    exit;
                }
            }
        }
        $base = dba_fetch($file, $db);
        /**/
    } else {
        $base = md5($file) . '.' . substr(md5(PATCHWORK_PROJECT_PATH), -6) . '.path.txt';
        $base = PATCHWORK_ZCACHE . $base[0] . '/' . $base[1] . '/' . $base;
        if (file_exists($base)) {
            $base = file_get_contents($base);
        } else {
            $base = false;
        }
        /**/
    }
    if (false !== $base) {
        $base = explode(',', $base);
        do {
            if (current($base) >= $i) {
                $base = (int) current($base);
                $last_level = $level - $base + $i;
                /**/
                if ('\\' === DIRECTORY_SEPARATOR) {
                    false !== strpos($file, '/') && ($file = strtr($file, '/', '\\'));
                }
                return $GLOBALS['patchwork_path'][$base] . (0 <= $last_level ? $file : substr($file, 6)) . ($slash ? DIRECTORY_SEPARATOR : '');
            }
        } while (false !== next($base));
    }
    return false;
}
开发者ID:nicolas-grekas,项目名称:Patchwork,代码行数:85,代码来源:bootup.patchwork.php

示例8: dirname

<?php

require_once dirname(__FILE__) . '/test.inc';
echo "database handler: {$handler}\n";
if (($db = dba_popen($db_file, "n", $handler)) !== FALSE) {
    echo "Opened\n";
    dba_insert("a", "Inserted", $db);
    echo dba_fetch("a", $db) . "\n";
    dba_close($db);
    echo "Closed\n";
} else {
    echo "Error creating database\n";
}
if (($db = dba_popen($db_file, "n", $handler)) !== FALSE) {
    echo "Opened\n";
    dba_insert("a", "Inserted", $db);
    echo dba_fetch("a", $db) . "\n";
}
开发者ID:zaky-92,项目名称:php-1,代码行数:18,代码来源:ext_dba_tests_dba009.php

示例9: __construct

 function __construct($path = "oauth.gdbm", $request_expiration = null, $access_expiration = null, $session_expiraton = null)
 {
     /*{{{*/
     $this->dbh = dba_popen($path, 'c', 'gdbm');
     if (!empty($request_expiration)) {
         $this->request_expiration = $request_expiration;
     }
     if (!empty($access_expiration)) {
         $this->access_expiration = $access_expiration;
     }
     if (!empty($session_expiraton)) {
         $this->session_expiration = $session_expiraton;
     }
 }
开发者ID:srouthiau,项目名称:oauth,代码行数:14,代码来源:OAuth.php

示例10: BDB

 /**
  * Constructor Method.  Establishes a connection to the database,
  * which can be verified by an if ($dbd->connection) {.
  * 
  * @access	public
  * @param	string	$path
  * @param	string	$mode
  * @param	string	$handler
  * @param	boolean	$persistent
  * 
  */
 function BDB($path, $mode = 'r', $handler = 'db3', $persistent = 0)
 {
     $this->path = $path;
     $this->mode = $mode;
     $this->handler = $handler;
     $this->persistent = $persistent;
     if ($persistent) {
         $this->connection = @dba_popen($path, $mode, $handler);
     } else {
         $this->connection = @dba_open($path, $mode, $handler);
     }
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:23,代码来源:BDB.php

示例11: __construct

 function __construct($path = 'conf/oauth.gdbm')
 {
     /*{{{*/
     /// XX DOKU_CONF
     $this->dbh = dba_popen($path, 'c', 'inifile');
 }
开发者ID:x42,项目名称:dokuoauth,代码行数:6,代码来源:OAuth_DokuServer.php

示例12: _connect

 protected function _connect()
 {
     if (isset($this->_profile['file']) && $this->_profile['file'] != '') {
         $this->_file = str_replace(array('var:', 'temp:'), array(jApp::varPath(), jApp::tempPath()), $this->_profile['file']);
     } else {
         throw new Exception('No file in the configuration of the dba driver for jKVDB');
     }
     $mode = "cl";
     if (isset($this->_profile['handler']) && $this->_profile['handler'] != '') {
         $handler = $this->_profile['handler'];
     } else {
         throw new Exception('No handler in the configuration of the dba driver for jKVDB');
     }
     if (isset($this->_profile['persistant']) && $this->_profile['persistant']) {
         $conn = dba_popen($this->_file, $mode, $handler);
     } else {
         $conn = dba_open($this->_file, $mode, $handler);
     }
     if ($conn === false) {
         return null;
     }
     return $conn;
 }
开发者ID:medali1990,项目名称:medsite,代码行数:23,代码来源:dba.kvdriver.php

示例13: dirname

<?php

$handler = "db4";
require_once dirname(__FILE__) . '/test.inc';
echo "database handler: {$handler}\n";
echo "Test 1\n";
$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
dba_insert("key1", "This is a test insert 1", $db_file1);
echo dba_fetch("key1", $db_file1), "\n";
echo "Test 2\n";
$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
if ($db_file1 === $db_file2) {
    echo "resources are the same\n";
} else {
    echo "resources are different\n";
}
echo "Test 3 - fetch both rows from second resource\n";
dba_insert("key2", "This is a test insert 2", $db_file2);
echo dba_fetch("key1", $db_file2), "\n";
echo dba_fetch("key2", $db_file2), "\n";
echo "Test 4 - fetch both rows from first resource\n";
echo dba_fetch("key1", $db_file1), "\n";
echo dba_fetch("key2", $db_file1), "\n";
echo "Test 5 - close 2nd resource\n";
dba_close($db_file2);
var_dump($db_file1);
var_dump($db_file2);
echo "Test 6 - query after closing 2nd resource\n";
echo dba_fetch("key1", $db_file1), "\n";
echo dba_fetch("key2", $db_file1), "\n";
?>
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_dba_tests_dba_db4_018.php

示例14: _log

 private function _log($m = null)
 {
     /*{{{*/
     $OAdebug = $this->getConf('log_all_requests');
     $OAlogdb = '/tmp/oAuth.log';
     $dbh = dba_popen($OAlogfile, 'c', 'inifile');
     if (!isset($OAlog) || $OAlog === false) {
         return;
     }
     $data = array('REMOTE_USER' => $_SERVER['REMOTE_USER'], 'HTTP_USER_AGENT' => $_SERVER['HTTP_USER_AGENT'], 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], 'REMOTE_PORT' => $_SERVER['REMOTE_PORT'], 'HTTP_X_REAL_IP' => $_SERVER['HTTP_X_REAL_IP'], 'HTTP_X_FORWARDED_FOR' => $_SERVER['HTTP_X_FORWARDED_FOR'], 'HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'], 'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'], 'REQUEST_URI' => $_SERVER['REQUEST_URI'], 'QUERY_STRING' => $_SERVER['QUERY_STRING'], 'REQUEST_TIME' => $_SERVER['REQUEST_TIME'], 'GET' => $_GET, 'POST' => $_POST, 'REQUEST' => $_REQUEST, 'msg' => $m);
     if (!$dbh || !dba_insert("log_{$token}", serialize($data), $dbh)) {
         header("HTTP/1.1 500 Internal Server Error");
         echo 'Cannot write to log: ' . $OAlogdb;
         return;
     }
     dba_close($this->dbh);
 }
开发者ID:x42,项目名称:dokuoauth,代码行数:17,代码来源:action.php

示例15: _load

 function _load($fpath)
 {
     $ext = strrchr($fpath, '.');
     $type = $ext ? strtolower(substr($ext, 1)) : 'gdbm';
     if (!in_array($type, dba_handlers())) {
         trigger_error("您的 dba 扩展不支持 `{$type}` 这一数据类型", E_USER_ERROR);
     }
     $this->_dbh = dba_popen($fpath, 'r', $type);
     if (!$this->_dbh) {
         trigger_error("无法打开类型为 `{$type}` 的 dba 数据文件 `{$fpath}`", E_USER_ERROR);
     }
 }
开发者ID:lamphp,项目名称:scws,代码行数:12,代码来源:dict.class.php


注:本文中的dba_popen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。