Source for file Database.interface.php

Documentation is available at Database.interface.php

  1. <?php
  2.  
  3. /**
  4. * A Database interface provides generic database functionality: connect(), executeQuery(), etc.
  5. * The interface can be implemented for different types of databases: MySQL, Oracle, SQLServer, etc.
  6. *
  7. * @package harmoni.dbc
  8. *
  9. * @copyright Copyright &copy; 2005, Middlebury College
  10. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  11. *
  12. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  13. */
  14. interface Database {
  15.  
  16. /**
  17. * Connects to the database.
  18. * Connects to the database.
  19. * @access public
  20. * @return mixed The connection's link identifier, if successful; False, otherwise.
  21. */
  22. function connect();
  23.  
  24. /**
  25. /**
  26. * Makes a persistent database connection.
  27. * Makes a persistent database connection.
  28. * @access public
  29. * @return mixed The connection's link identifier, if successful; False, otherwise.
  30. */
  31. function pConnect();
  32.  
  33.  
  34. /**
  35. /**
  36. * Executes an SQL query.
  37. * Executes an SQL query. The method is passed a query object, which it
  38. * converts to a SQL query string using the appropriate SQLGenerator
  39. * object.
  40. * @access public
  41. * @param object Query $query A Query object from which the SQL query will be constructed.
  42. * @return mixed The appropriate QueryResult object. If the query failed, it would
  43. * return NULL.
  44. */
  45. function query(Query $query);
  46.  
  47.  
  48. /**
  49. /**
  50. * Disconnects from the database.
  51. * Disconnects from the database.
  52. * @access public
  53. * @return boolean True, if successful; False, otherwise.
  54. */
  55. function disconnect();
  56. /**
  57. /**
  58. * Indicates whether there is an open connection to the database.
  59. * Indicates whether there is an open connection to the database.
  60. * @access public
  61. * @return boolean True, if there is an open connection to the database; False, otherwise.
  62. */
  63. function isConnected();
  64.  
  65. /**
  66. /**
  67. * Returns a list of the tables that exist in the currently connected database.
  68. * @return array
  69. * @access public
  70. */
  71. function getTableList();
  72. /**
  73. /**
  74. * Returns the total number of successful queries executed since the last call to connect().
  75. * Returns the total number of successful queries executed since the last call to connect().
  76. * @access public
  77. * @return integer The total number of successful queries executed since the last call to connect().
  78. ***/
  79. function getNumberSuccessfulQueries();
  80. /**
  81. /**
  82. * Returns the total number of failed queries executed since the last call to connect().
  83. * Returns the total number of failed queries executed since the last call to connect().
  84. * @access public
  85. * @return integer The total number of failed queries executed since the last call to connect().
  86. ***/
  87. function getNumberFailedQueries();
  88. /**
  89. /**
  90. * This method selects the default database to use in queries.
  91. * @access public
  92. * @param string database The name of the default database.
  93. * @return boolean True, if successful; False, otherwise.
  94. */
  95. function selectDatabase($database);
  96. /**
  97. /**
  98. * Converts a DateAndTime object to a proper datetime/timestamp/time representation
  99. * for this Database. This function must return a string including quotes if necessary
  100. * for this specific database type.
  101. * @access public
  102. * @param ref object DateAndTime The DateAndTime object to convert.
  103. * @return mixed A proper datetime/timestamp/time representation for this Database.
  104. */
  105. function toDBDate(DateAndTime $dateAndTime);
  106. /**
  107. /**
  108. * Converts a database datetime/timestamp/time value (that has been fetched
  109. * from the db) to a DateAndTime object.
  110. * @access public
  111. * @param mixed A database datetime/timestamp/time value (that has been fetched
  112. * from the db).
  113. * @return ref object The DateAndTime object.
  114. */
  115. function fromDBDate($value);
  116. /**
  117. /**
  118. * Return TRUE if this database supports transactions.
  119. *
  120. * @return boolean
  121. * @access public
  122. * @since 3/9/05
  123. */
  124. function supportsTransactions ();
  125. /**
  126. /**
  127. * Begin a transaction.
  128. *
  129. * @return void
  130. * @access public
  131. * @since 3/9/05
  132. */
  133. function beginTransaction ();
  134. /**
  135. /**
  136. * Commit a transaction. This will roll-back changes if errors occured in the
  137. * transaction block.
  138. *
  139. * @return void
  140. * @access public
  141. * @since 3/9/05
  142. */
  143. function commitTransaction ();
  144. /**
  145. /**
  146. * Roll-back a transaction manually instead of committing
  147. *
  148. * @return void
  149. * @access public
  150. * @since 3/9/05
  151. */
  152. function rollbackTransaction ();
  153. /**
  154. /**
  155. * Returns a short string name for this database type. Example: 'MySQL'
  156. * @access public
  157. * @return string
  158. */
  159. function getStringName();
  160. /**
  161. /**
  162. * Answer the info to display to users on a connection error.
  163. *
  164. * @return string
  165. * @access public
  166. * @since 6/1/06
  167. */
  168. function getConnectionErrorInfo ();
  169.  
  170.  
  171.  
  172. /**
  173. * This is the root exception for all database exceptions.
  174. *
  175. * @since 9/5/07
  176. * @package harmoni.dbc
  177. *
  178. * @copyright Copyright &copy; 2007, Middlebury College
  179. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  180. *
  181. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  182. */
  183. class DatabaseException
  184. extends HarmoniException
  185. {
  186. }
  187.  
  188. /**
  189. * This is an exception thrown for connection problems.
  190. *
  191. * @since 9/5/07
  192. * @package harmoni.dbc
  193. *
  194. * @copyright Copyright &copy; 2007, Middlebury College
  195. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  196. *
  197. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  198. */
  199. class ConnectionDatabaseException
  200. extends DatabaseException
  201. {
  202.  
  203. }
  204.  
  205. /**
  206. * This is an exception thrown in response to errors in transaction usage.
  207. *
  208. * @since 9/5/07
  209. * @package harmoni.dbc
  210. *
  211. * @copyright Copyright &copy; 2007, Middlebury College
  212. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  213. *
  214. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  215. */
  216. class TransactionDatabaseException
  217. extends DatabaseException
  218. {
  219.  
  220. }
  221.  
  222. /**
  223. * This is an exception thrown in response to an error that occurs in query execution.
  224. *
  225. * @since 9/5/07
  226. * @package harmoni.dbc
  227. *
  228. * @copyright Copyright &copy; 2007, Middlebury College
  229. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  230. *
  231. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  232. */
  233. class QueryDatabaseException
  234. extends DatabaseException
  235. {
  236.  
  237. }
  238.  
  239. /**
  240. * This is an exception thrown when the query size exceeds the maximum that
  241. * can be sent to the server.
  242. *
  243. * @since 9/5/07
  244. * @package harmoni.dbc
  245. *
  246. * @copyright Copyright &copy; 2007, Middlebury College
  247. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  248. *
  249. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  250. */
  251. class QuerySizeDatabaseException
  252. extends QueryDatabaseException
  253. {
  254.  
  255. }
  256.  
  257. /**
  258. * This exception is thrown when an insert or update query causes a duplicate-key
  259. * error. As these often to not cause data inconsistancies, they can often be
  260. * caught and ignored.
  261. *
  262. * @since 9/5/07
  263. * @package harmoni.dbc
  264. *
  265. * @copyright Copyright &copy; 2007, Middlebury College
  266. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  267. *
  268. * @version $Id: Database.interface.php,v 1.11 2007/09/05 21:38:59 adamfranco Exp $
  269. */
  270. class DuplucateKeyDatabaseException
  271. extends DatabaseException
  272. {
  273.  
  274. }
  275.  
  276. ?>

Documentation generated on Wed, 19 Sep 2007 10:22:28 -0400 by phpDocumentor 1.3.0RC3