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

Source for file PMO_Dbms.php

Documentation is available at PMO_Dbms.php

  1. <?php
  2. /**
  3.  * This file contains the PMO_Dbms interface.
  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.1x
  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 interface defines the methods a class must implement
  39.  * to provide a working Dbms driver class.
  40.  * 
  41.  * @package        PhpMyObject
  42.  * @subpackage PMO_Core
  43.  * @see            PMO_MyDbms
  44.  */ 
  45. interface PMO_Dbms {
  46.     
  47.     /**
  48.      * The implementatio must create a PMO_MyDbms object or if it already
  49.      * exists, return a reference of this object instance
  50.      *
  51.      * @param object $object    a optional PDO object to use.
  52.      * @return PMO_Dbms 
  53.      * @static
  54.      */
  55.     static function factory(PDO $object null);
  56.     
  57.     /**
  58.      * The implementation must create a data link with the database
  59.      *
  60.      * @param array $authdb        an array containing the needed connection info
  61.      * @see PMO_MyConfig
  62.      */
  63.     public function connect(array $authdb);
  64.     
  65.     /**
  66. /**
  67.      * The implementation must return the DB link or DB object
  68.      *
  69.      * @return object|resource       either a Dbms object or a resource link
  70.      */
  71.     public function getDB();
  72.  
  73.     /**
  74.      * The implementation must set a DB link or DD object
  75.      *
  76.      * @param object|resource$object 
  77.      */
  78.     public function setDB($object);
  79.     
  80.     /**
  81.      * The implementation must implement a method that will
  82.      * execute an SQL query and return true if everything is ok
  83.      * or thow an eception if no result is found
  84.      * 
  85.      * @param string $query            the SQL query to execute
  86.      * @return bool                    true if results are found
  87.      * @throws Exception                if no result is found
  88.      */
  89.     public function query($query);
  90.  
  91.     /**
  92.      * the implemetation must returns the query results
  93.      *
  94.      * @return array 
  95.      */
  96.     public function fetchArray();
  97.  
  98.     /**
  99.      * the implementation must an array containing the table properties
  100.      *
  101.      * query database for a description of the $table schems
  102.      *
  103.      * like a :
  104.      * DESC $table;
  105.      * DESCRIBE $table;
  106.      * SHOW $table;
  107.      *
  108.      * @param sint $table        the table name to work on
  109.      * @return array 
  110.      */
  111.     public function getTableDesc($table);
  112.     
  113.     /** 
  114.      * the implementation must return the last inserted primary key value
  115.      *
  116.      * @return int 
  117.      */
  118.     public function getLastId();
  119.  
  120.     /**
  121.      * the implementation must load data from the database
  122.      * and fill the passed in PMO_Object with it
  123.      *
  124.      * @return void 
  125.      * @throws Exception
  126.      */
  127.     public function load(PMO_Object $object);    
  128.  
  129.     /**
  130.      * the implementation must update the data corresponding to the
  131.      * PMO_Object in database All primary keys must be fill.
  132.      *
  133.      * @return TRUE 
  134.      * @throws Exception
  135.      */    
  136.     public function update(PMO_Object $object);
  137.     
  138.     /**
  139.      * the implementation must delete data corresponding to the PMO_Object
  140.      * in database All primary key must be fill.
  141.      * 
  142.      * @return TRUE 
  143.      * @throws Exception
  144.      */
  145.     public function delete(PMO_Object $object);
  146.  
  147.     /**
  148.      * the implementation must insert new data in database
  149.      * corresponding to the PMO_Object
  150.      * all primary keys must be fill.
  151.      * 
  152.      * @return TRUE 
  153.      * @throws Exception
  154.      */        
  155.     public function insert(PMO_Object $object);    
  156.     
  157.     /**
  158.      * the implementation must start a transaction
  159.      */
  160.     public function beginTransaction();
  161.  
  162.     /**
  163.      * the implementation must rollback an already stated transaction
  164.      */
  165.     public function rollback();
  166.  
  167.     /**
  168.      * the implemetation ust commit the started transaction
  169.      */
  170.     public function commit();
  171. }
  172. ?>

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