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

Source for file PMO_Dbms_Pgsql.php

Documentation is available at PMO_Dbms_Pgsql.php

  1. <?php
  2. /**
  3.  * This file contains the PMO_Dbms_Pgsql 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.1
  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 PostgreSql driver.
  39.  * 
  40.  * @package        PhpMyObject
  41.  * @subpackage PMO_Core
  42.  */
  43. class PMO_Dbms_Pgsql extends PMO_MyDbms {
  44.  
  45.     public function __construct($pgsqllink NULL{
  46.         if(isset($pgsqllink))
  47.             $this->setDb($pgsqllink);
  48.     }
  49.     
  50.     public function connect(array $authdb){
  51.             $this->setDb(pg_connect("host={$authdb[host]} dbname={$authdb[base]} user={$authdb[user]} password={$authdb[pass]}"))
  52.             or die(pg_last_error());
  53.     }
  54.     
  55.     public function __destruct({
  56.         @pg_close($this->getDb());
  57.     }
  58.  
  59.     public function query($query){
  60.         $this->result pg_query($query);
  61.         if($this->result)
  62.             return TRUE;
  63.         else
  64.             throw new Exception($query);
  65.     }
  66.  
  67.     public function fetchArray({
  68.             return pg_fetch_assoc($this->result);
  69.     }
  70.  
  71.     public function getTableDesc($table{
  72.         $this->result pg_query_params('
  73.             SELECT f.column_name AS "Field",
  74.                 CASE 
  75.                     WHEN c.contype=\'p\' THEN \'PRI\'
  76.                     ELSE \'NULL\'
  77.                 END AS "Key"
  78.             FROM
  79.                 information_schema.columns AS f
  80.                 LEFT JOIN (
  81.                     information_schema.constraint_column_usage cu
  82.                         JOIN pg_catalog.pg_constraint AS c ON (cu.constraint_name = c.conname))
  83.                 ON (f.column_name=cu.column_name AND f.table_name=cu.table_name)
  84.             WHERE
  85.                 f.table_name = $1'array(addslashes($table)));
  86.             
  87.         if(!$this->result)
  88.             throw new Exception(pg_last_error());
  89.         
  90.         while($dbresult $this->fetchArray()){
  91.             $tmparray[array("Field"=>$dbresult['Field']
  92.                                 "Type" => $this->translateType($dbresult['Type'])
  93.                                 "Null" => $dbresult['Null']
  94.                                 "Key"=>$dbresult['Key']
  95.                                 "Default"=>$dbresult['Default']
  96.                                 "Extra"=>$dbresult['Extra'],
  97.                                 "Perm"=>"rw");
  98.         }
  99.         return $tmparray;    
  100.             
  101.     }
  102.     
  103.     public function getLastId({
  104.         
  105.     }
  106.  
  107.     public function beginTransaction(){
  108.         
  109.     }
  110.     
  111.     public function rollback(){
  112.         
  113.     }
  114.     
  115.     public function commit(){
  116.         
  117.     }    
  118. }
  119. ?>

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