--INI--
psi.directory={PWD}:{PWD}/../../psi.d
--SKIPIF--
-<?php
+<?php
extension_loaded("psi") or die("skip - need ext/psi");
function_exists("psi\\dbm_open") or die("skip - need nbdm support");
?>
--FILE--
===TEST===
-<?php
+<?php
class db {
private $db;
-
- function __construct($file = "ndbm001.db", $o = psi\O_CREAT|psi\O_RDWR, $m = 0640) {
+
+ function __construct($file = __DIR__."/ndbm001.db", $o = psi\O_CREAT|psi\O_RDWR, $m = 0640) {
if (!$this->db = psi\dbm_open($file, $o, $m)) {
throw new Exception(psi\strerror(psi\errno()));
}
}
-
+
function __destruct() {
psi\dbm_close($this->db);
}
-
+
function __set($k, $v) {
return psi\dbm_store($this->db, [
- "dptr" => $k,
+ "dptr" => $k,
"dsize" => strlen($k)
], [
"dptr" => $v,
"dsize" => strlen($v)
], psi\DBM_REPLACE);
}
-
+
function __get($k) {
$val = psi\dbm_fetch($this->db, [
"dptr" => $k,
?>
===DONE===
--CLEAN--
-<?php
-@unlink("ndbm001.db");
+<?php
+array_map("unlink", glob(__DIR__."/ndbm001.db*"));
?>
--EXPECT--
===TEST===