phpPoA2
[ class tree: phpPoA2 ] [ index: phpPoA2 ] [ all elements ]

Source for file DBADB.php

Documentation is available at DBADB.php

  1. <?php
  2. /**
  3.  * @copyright Copyright 2005-2010 RedIRIS, http://www.rediris.es/
  4.  *
  5.  *  This file is part of phpPoA2.
  6.  *  
  7.  *  phpPoA2 is free software: you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation, either version 3 of the License, or
  10.  *  (at your option) any later version.
  11.  *  
  12.  *  phpPoA2 is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with phpPoA2. If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
  21.  * @version 2.0
  22.  * @author Jaime Perez <jaime.perez@rediris.es>
  23.  * @filesource
  24.  */
  25.  
  26. /**
  27.  * Berkeley DB backend.
  28.  * @package phpPoA2
  29.  * @subpackage GenericDatabaseHandlers
  30.  */
  31. class DBADB extends GenericDB {
  32.  
  33.     protected $mandatory_options = array("DBFile");
  34.  
  35.     protected function configure({
  36.         if (!extension_loaded("dba")) {
  37.             trigger_error(PoAUtils::msg('extension-required'array("dba"))E_USER_ERROR);
  38.         }
  39.         parent::configure();
  40.     }
  41.  
  42.     public function open({
  43.         $this->db = @dba_open($this->cfg->getDBFile()"cl""db4");
  44.         return ($this->dbtrue false;
  45.     }
  46.  
  47.     public function check($key{
  48.         return @dba_exists($key$this->db);
  49.     }
  50.  
  51.     public function replace($key$value{
  52.         $result @dba_replace($key$value$this->db);
  53.         dba_sync($this->db);
  54.         return $result;
  55.     }
  56.  
  57.     public function fetch($key{
  58.         return @dba_fetch($key$this->db);
  59.     }
  60.  
  61.     public function fetch_all({
  62.         $list array();
  63.         $key @dba_firstkey($this->db);
  64.         while ($key{
  65.             $list[$key@dba_fetch($key$this->db);
  66.             $key @dba_nextkey($this->db);
  67.         }
  68.         return $list;
  69.     }
  70.  
  71.     public function delete($key{
  72.         $result @dba_delete($key$this->db);
  73.         dba_optimize($this->db);
  74.         dba_sync($this->db);
  75.         return $result;
  76.     }
  77.  
  78.     public function close({
  79.         return @dba_close($this->db);
  80.     }
  81. }
  82.  
  83. ?>

Documentation generated on Tue, 25 Jan 2011 11:24:29 +0100 by phpDocumentor 1.4.3