From: <var...@us...> - 2014-11-08 16:15:17
|
Revision: 9287 http://sourceforge.net/p/phpwiki/code/9287 Author: vargenau Date: 2014-11-08 16:15:14 +0000 (Sat, 08 Nov 2014) Log Message: ----------- function _error is void Modified Paths: -------------- trunk/lib/DbaDatabase.php Modified: trunk/lib/DbaDatabase.php =================================================================== --- trunk/lib/DbaDatabase.php 2014-11-08 15:54:20 UTC (rev 9286) +++ trunk/lib/DbaDatabase.php 2014-11-08 16:15:14 UTC (rev 9287) @@ -9,7 +9,22 @@ class DbaDatabase { - function DbaDatabase($filename, $mode = false, $handler = 'gdbm') + public $_file; + public $_handler; + public $_timeout; + /** + * @var resource + */ + public $_dbh; + public $readonly; + public $_dba_open_error; + + /** + * @param string $filename + * @param bool $mode + * @param string $handler + */ + function __construct($filename, $mode = false, $handler = 'gdbm') { $this->_file = $filename; $this->_handler = $handler; @@ -34,7 +49,7 @@ function open($mode = 'w') { if ($this->_dbh) - return; // already open. + return true; // already open. $watchdog = $this->_timeout; @@ -122,21 +137,22 @@ function fetch($key) { $val = dba_fetch($key, $this->_dbh); - if ($val === false) - return $this->_error("fetch($key)"); + if ($val === false) { + $this->_error("fetch($key)"); + } return $val; } function insert($key, $val) { if (!dba_insert($key, $val, $this->_dbh)) - return $this->_error("insert($key)"); + $this->_error("insert($key)"); } function replace($key, $val) { if (!dba_replace($key, $val, $this->_dbh)) - return $this->_error("replace($key)"); + $this->_error("replace($key)"); } function firstkey() @@ -151,9 +167,10 @@ function delete($key) { - if ($this->readonly) return; + if ($this->readonly) + return; if (!dba_delete($key, $this->_dbh)) - return $this->_error("delete($key)"); + $this->_error("delete($key)"); } function get($key) @@ -164,38 +181,37 @@ function set($key, $val) { $dbh = &$this->_dbh; - if ($this->readonly) return; + if ($this->readonly) + return; if (dba_exists($key, $dbh)) { if ($val !== false) { if (!dba_replace($key, $val, $dbh)) - return $this->_error("store[replace]($key)"); + $this->_error("store[replace]($key)"); } else { if (!dba_delete($key, $dbh)) - return $this->_error("store[delete]($key)"); + $this->_error("store[delete]($key)"); } } else { if (!dba_insert($key, $val, $dbh)) - return $this->_error("store[insert]($key)"); + $this->_error("store[insert]($key)"); } } function sync() { if (!dba_sync($this->_dbh)) - return $this->_error("sync()"); + $this->_error("sync()"); } function optimize() { if (!dba_optimize($this->_dbh)) - return $this->_error("optimize()"); + $this->_error("optimize()"); return 1; } - function _error($mes) + private function _error($mes) { - //trigger_error("DbaDatabase: $mes", E_USER_WARNING); - //return false; trigger_error("$this->_file: dba error: $mes", E_USER_ERROR); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |