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

Source for file PMO_Dbms_Mysqli.php

Documentation is available at PMO_Dbms_Mysqli.php

  1. <?php
  2. /**
  3.  * This file contains the PMO_Dbms_Mysqli driver class.
  4.  *
  5.  * This file is part of the PhpMyObject project,
  6.  * an Object-Relational Mapping (ORM) system.
  7.  * 
  8.  * For questions, help, comments, discussion, etc., please join our
  9.  * forum at {@link http://www.developpez.net/forums/forumdisplay.php?f=770}
  10.  * or our mailing list at {@link http://groups.google.com/group/pmo-dev}.
  11.  *
  12.  * PhpMyObject is free software: you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation, either version 3 of the License, or
  15.  * (at your option) any later version.
  16.  *
  17.  * This program is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with this program.  If not, see {@link http://www.gnu.org/licenses/}.
  24.  *
  25.  * @package        PhpMyObject
  26.  * @subpackage PMO_Core
  27.  * @author        Nicolas Boiteux <nicolas_boiteux@yahoo.fr>
  28.  * @link            http://pmo.developpez.com/
  29.  * @since        PhpMyObject v0.14
  30.  * @version        $Revision: $
  31.  * @copyright    Copyright (C) 2007-2008 Nicolas Boiteux
  32.  * @license        GPLv3 {@link http://www.gnu.org/licenses/gpl}
  33.  * @filesource
  34.  *
  35.  */ 
  36.  
  37. /**
  38.  * This class implements a MySqli driver.
  39.  * 
  40.  * @package        PhpMyObject
  41.  * @subpackage PMO_Core
  42.  */
  43. class PMO_Dbms_Mysqli extends PMO_MyDbms {
  44.  
  45.     public function __construct($mysqllink NULL{
  46.         if(isset($mysqllink))
  47.             $this->setDB($mysqllink);
  48.     }
  49.  
  50.     public function connect(array $authdb){
  51.         $this->setDB(new mysqli($authdb['host']$authdb['user']$authdb['pass']$authdb['base']));
  52.         
  53.         if(!$this->getDB())
  54.             throw new Exception(mysqli_connect_errno());
  55.         
  56.     }
  57.  
  58.     public function __destruct({
  59.         $this->getDB()->close();
  60.     }
  61.  
  62.     public function query($query){
  63.         $this->result $this->getDB()->query($query);
  64.         if($this->result)
  65.             return TRUE;
  66.         else
  67.             throw new Exception($query." ".$this->getDB()->error());
  68.     }
  69.  
  70.     public function fetchArray({
  71.             return $this->result->fetch_assoc();
  72.     }
  73.  
  74.     public function getTableDesc($table{
  75.         $sql sprintf('DESC %s'addslashes($table));
  76.         $this->query($sql);
  77.         
  78.         while($dbresult $this->fetchArray()){
  79.             $tmparray[array("Field"=>$dbresult['Field']
  80.                                 "Type" => $this->translateType($dbresult['Type'])
  81.                                 "Null" => $dbresult['Null']
  82.                                 "Key"=>$dbresult['Key']
  83.                                 "Default"=>$dbresult['Default']
  84.                                 "Extra"=>$dbresult['Extra'],
  85.                                 "Perm"=>"rw");
  86.         }
  87.         return $tmparray;
  88.     }
  89.     
  90.     public function getLastId({
  91.         return $this->getDb()->mysqli_insert_id();
  92.     }
  93.  
  94.     public function beginTransaction(){
  95.         $this->getDB()->autocommit(FALSE);
  96.     }
  97.     
  98.     public function rollback(){
  99.         return $this->getDB()->rollback();
  100.     }
  101.     
  102.     public function commit(){
  103.         return $this->getDB()->commit();
  104.     }
  105. }
  106. ?>

Documentation generated on Wed, 15 Oct 2008 09:15:45 -0400 by phpDocumentor 1.4.1