|
| 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 <[email protected]> |
| 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 | + * The implementation must return the DB link or DB object |
| 67 | + * |
| 68 | + * @return object|resource either a Dbms object or a resource link |
| 69 | + */ |
| 70 | + public function getDB(); |
| 71 | + |
| 72 | + /** |
| 73 | + * The implementation must set a DB link or DD object |
| 74 | + * |
| 75 | + * @param object|resource $object |
| 76 | + */ |
| 77 | + public function setDB($object); |
| 78 | + |
| 79 | + /** |
| 80 | + * The implementation must implement a method that will |
| 81 | + * execute an SQL query and return true if everything is ok |
| 82 | + * or thow an eception if no result is found |
| 83 | + * |
| 84 | + * @param string $query the SQL query to execute |
| 85 | + * @return bool true if results are found |
| 86 | + * @throws Exception if no result is found |
| 87 | + */ |
| 88 | + public function query($query); |
| 89 | + |
| 90 | + /** |
| 91 | + * the implemetation must returns the query results |
| 92 | + * |
| 93 | + * @return array |
| 94 | + */ |
| 95 | + public function fetchArray(); |
| 96 | + |
| 97 | + /** |
| 98 | + * the implementation must an array containing the table properties |
| 99 | + * |
| 100 | + * query database for a description of the $table schems |
| 101 | + * |
| 102 | + * like a : |
| 103 | + * DESC $table; |
| 104 | + * DESCRIBE $table; |
| 105 | + * SHOW $table; |
| 106 | + * |
| 107 | + * @param sint $table the table name to work on |
| 108 | + * @return array |
| 109 | + */ |
| 110 | + public function getTableDesc($table); |
| 111 | + |
| 112 | + /** |
| 113 | + * the implementation must return the last inserted primary key value |
| 114 | + * |
| 115 | + * @return int |
| 116 | + */ |
| 117 | + public function getLastId(); |
| 118 | + |
| 119 | + /** |
| 120 | + * the implementation must load data from the database |
| 121 | + * and fill the passed in PMO_Object with it |
| 122 | + * |
| 123 | + * @return void |
| 124 | + * @throws Exception |
| 125 | + */ |
| 126 | + public function load(PMO_Object $object); |
| 127 | + |
| 128 | + /** |
| 129 | + * the implementation must update the data corresponding to the |
| 130 | + * PMO_Object in database All primary keys must be fill. |
| 131 | + * |
| 132 | + * @return TRUE |
| 133 | + * @throws Exception |
| 134 | + */ |
| 135 | + public function update(PMO_Object $object); |
| 136 | + |
| 137 | + /** |
| 138 | + * the implementation must delete data corresponding to the PMO_Object |
| 139 | + * in database All primary key must be fill. |
| 140 | + * |
| 141 | + * @return TRUE |
| 142 | + * @throws Exception |
| 143 | + */ |
| 144 | + public function delete(PMO_Object $object); |
| 145 | + |
| 146 | + /** |
| 147 | + * the implementation must insert new data in database |
| 148 | + * corresponding to the PMO_Object |
| 149 | + * all primary keys must be fill. |
| 150 | + * |
| 151 | + * @return TRUE |
| 152 | + * @throws Exception |
| 153 | + */ |
| 154 | + public function insert(PMO_Object $object); |
| 155 | + |
| 156 | + /** |
| 157 | + * the implementation must start a transaction |
| 158 | + */ |
| 159 | + public function beginTransaction(); |
| 160 | + |
| 161 | + /** |
| 162 | + * the implementation must rollback an already stated transaction |
| 163 | + */ |
| 164 | + public function rollback(); |
| 165 | + |
| 166 | + /** |
| 167 | + * the implemetation ust commit the started transaction |
| 168 | + */ |
| 169 | + public function commit(); |
| 170 | +} |
| 171 | +?> |
0 commit comments