Source for file Query.class.php

Documentation is available at Query.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Query
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Query Interface
  22.  * 
  23.  * This interface was designed to create a common class for a program to
  24.  * execute database queries (select,insert,update,delete).  By using a common
  25.  * interface, any changes made to the database engine (PDO, ADODB, PEAR_DB, etc)
  26.  * can be reflected in a Query class, and not the entire program.  For example,
  27.  * if a program is written for PEAR_DB, but a decision was made to switch to
  28.  * PDO, the transition is made much easier when the implementation is in one
  29.  * location.  Imagine having to search through thousands of lines of code and
  30.  * change the implementation from PEAR_DB to PDO.
  31.  *
  32.  * @category Gumbo
  33.  * @package Query
  34.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  35.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  36.  * @author Michael Luster <mluster79@yahoo.com>
  37.  * @link http://sourceforge.net/projects/phpgumbo
  38.  * @desc Query Interface
  39.  * @version 0.0.1
  40.  */
  41.  
  42. interface Gumbo_Interface_Query {
  43.     
  44.     /** ACTION METHODS **/
  45.     /**
  46.      * Returns an array of Items with the results of a "SELECT ... " query
  47.      * @param string $sql query to execute
  48.      * @param array $params token parameter values
  49.      * @return array 
  50.      */
  51.     public static function results ($sql$params=null);
  52.     
  53.     /**
  54.      * Executes the given query and returns the results
  55.      * 
  56.      * This is a Bridge between the DB interface and the Item class.  It
  57.      * will execute a sinle query and return the results.  If a SELECT
  58.      * is performed, then a single associative array representing a
  59.      * record is returned.  If an INSERT is performed, then the new insert
  60.      * ID is returned.  UPDATE and DELETE queries will not return anything.
  61.      * 
  62.      * @param string $sql 
  63.      * @param array $params list of parameters for the prepare method
  64.      * @param string $name sequence/column name for returning lastInsertId()
  65.      * @return mixed 
  66.      */
  67.     public static function execute ($sql$params=null$name=null);
  68.     
  69.     /**
  70.      * Prepares a query by substituting a token character with parameter values
  71.      * @param string $sql 
  72.      * @param array $params list of parameters
  73.      * @param string $token replacement token character
  74.      * @return string 
  75.      */
  76.     public static function prepare ($sql$params=null$token=null);
  77.     
  78. }
  79.  
  80. ?>