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

Source for file interface.php

Documentation is available at interface.php

  1. <?php
  2. /**
  3.  * @version        $Id: interface.php 4628 2012-05-06 19:56:43Z johanjanssens $
  4.  * @package     Koowa_Database
  5.  * @subpackage  Adapter
  6.  * @copyright    Copyright (C) 2007 - 2012 Johan Janssens. All rights reserved.
  7.  * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
  8.  * @link         http://www.nooku.org
  9.  */
  10.  
  11. /**
  12.  * Database Adapter Interface
  13.  *
  14.  * @author        Johan Janssens <johan@nooku.org>
  15.  * @package     Koowa_Database
  16.  * @subpackage  Adapter
  17.  */
  18. {
  19.     /**
  20.      * Get a database query object
  21.      *
  22.      * @return KDatabaseQuery 
  23.      */
  24.     public function getQuery(KConfig $config null);
  25.  
  26.     /**
  27.      * Connect to the db
  28.      *
  29.      * @return  KDatabaseAdapterAbstract 
  30.      */
  31.     public function connect();
  32.  
  33.     /**
  34.      * Reconnect to the db
  35.      *
  36.      * @return  KDatabaseAdapterAbstract 
  37.      */
  38.     public function reconnect();
  39.  
  40.     /**
  41.      * Disconnect from db
  42.      *
  43.      * @return  KDatabaseAdapterAbstract 
  44.      */
  45.     public function disconnect();
  46.  
  47.     /**
  48.      * Get the connection
  49.      *
  50.      * Provides access to the underlying database connection. Useful for when
  51.      * you need to call a proprietary method such as postgresql's lo_* methods
  52.      *
  53.      * @return resource 
  54.      */
  55.     public function getConnection();
  56.  
  57.     /**
  58.      * Set the connection
  59.      *
  60.      * @param     resource     The connection resource
  61.      * @return  KDatabaseAdapterAbstract 
  62.      */
  63.     public function setConnection($resource);
  64.  
  65.     /**
  66.      * Determines if the connection to the server is active.
  67.      *
  68.      * @return      boolean 
  69.      */
  70.     public function isConnected();
  71.  
  72.     /**
  73.      * Get the insert id of the last insert operation
  74.      *
  75.      * @return mixed The id of the last inserted row(s)
  76.      */
  77.      public function getInsertId();
  78.  
  79.     /**
  80.      * Retrieves the column schema information about the given table
  81.      *
  82.      * @param     string     A table name
  83.      * @return    KDatabaseSchemaTable 
  84.      */
  85.     public function getTableSchema($table);
  86.  
  87.     /**
  88.      * Lock a table.
  89.      *
  90.      * @param  string  Base name of the table.
  91.      * @param  string  Real name of the table.
  92.      * @return boolean True on success, false otherwise.
  93.      */
  94.     public function lockTable($base$name);
  95.  
  96.     /**
  97.      * Unlock a table.
  98.      *
  99.      * @return boolean True on success, false otherwise.
  100.      */
  101.     public function unlockTable();
  102.  
  103.     /**
  104.      * Preforms a select query
  105.      *
  106.      * Use for SELECT and anything that returns rows.
  107.      *
  108.      * @param    string      A full SQL query to run. Data inside the query should be properly escaped.
  109.      * @param    integer     The result maode, either the constant KDatabase::RESULT_USE or KDatabase::RESULT_STORE
  110.      *                          depending on the desired behavior. By default, KDatabase::RESULT_STORE is used. If you
  111.      *                          use KDatabase::RESULT_USE all subsequent calls will return error Commands out of sync
  112.      *                          unless you free the result first.
  113.      * @return  mixed         If successfull returns a result object otherwise FALSE
  114.      */
  115.     public function select($sql$mode KDatabase::RESULT_STORE);
  116.  
  117.     /**
  118.      * Preforms a show query
  119.      *
  120.      * @param    string|object       A full SQL query to run. Data inside the query should be properly escaped.
  121.      * @param   integer            The fetch mode. Controls how the result will be returned to the caller. This
  122.      *                              value must be one of the KDatabase::FETCH_* constants.
  123.      * @return  mixed             The return value of this function on success depends on the fetch type.
  124.      *                              In all cases, FALSE is returned on failure.
  125.      */
  126.     public function show($query$mode KDatabase::FETCH_ARRAY_LIST);
  127.  
  128.     /**
  129.      * Inserts a row of data into a table.
  130.      *
  131.      * Automatically quotes the data values
  132.      *
  133.      * @param string      The table to insert data into.
  134.      * @param array     An associative array where the key is the colum name and
  135.      *                      the value is the value to insert for that column.
  136.      * @return integer  If successfull the new rows primary key value, false is no row was inserted.
  137.      */
  138.     public function insert($tablearray $data);
  139.  
  140.     /**
  141. /**
  142.      * Updates a table with specified data based on a WHERE clause
  143.      *
  144.      * Automatically quotes the data values
  145.      *
  146.      * @param string     The table to update
  147.      * @param array      An associative array where the key is the column name and
  148.      *                       the value is the value to use ofr that column.
  149.      * @param mixed     A sql string or KDatabaseQuery object to limit which rows are updated.
  150.      * @return integer  If successfull the Number of rows affected, otherwise false
  151.      */
  152.     public function update($tablearray $data$where null);
  153.  
  154.     /**
  155. /**
  156.      * Deletes rows from the table based on a WHERE clause.
  157.      *
  158.      * @param string The table to update
  159.      * @param mixed  A query string or a KDatabaseQuery object to limit which rows are updated.
  160.      * @return integer Number of rows affected
  161.      */
  162.     public function delete($table$where);
  163.  
  164.     /**
  165.      * Use and other queries that don't return rows
  166.      *
  167.      * @param  string     The query to run. Data inside the query should be properly escaped.
  168.      * @param  integer     The result maode, either the constant KDatabase::RESULT_USE or KDatabase::RESULT_STORE
  169.      *                      depending on the desired behavior. By default, KDatabase::RESULT_STORE is used. If you
  170.      *                      use KDatabase::RESULT_USE all subsequent calls will return error Commands out of sync
  171.      *                      unless you free the result first.
  172.      * @throws KDatabaseException
  173.      * @return boolean     For SELECT, SHOW, DESCRIBE or EXPLAIN will return a result object.
  174.      *                      For other successful queries  return TRUE.
  175.      */
  176.     public function execute($sql$mode KDatabase::RESULT_STORE );
  177.  
  178.     /**
  179.      * Set the table prefix
  180.      *
  181.      * @param string The table prefix
  182.      * @return KDatabaseAdapterAbstract 
  183.      * @see KDatabaseAdapterAbstract::replaceTableNeedle
  184.      */
  185.     public function setTablePrefix($prefix);
  186.  
  187.      /**
  188.      * Get the table prefix
  189.      *
  190.      * @return string The table prefix
  191.      * @see KDatabaseAdapterAbstract::replaceTableNeedle
  192.      */
  193.     public function getTablePrefix();
  194.  
  195.     /**
  196.      * Get the table needle
  197.      *
  198.      * @return string The table needle
  199.      * @see KDatabaseAdapterAbstract::replaceTableNeedle
  200.      */
  201.     public function getTableNeedle();
  202.  
  203.     /**
  204.      * This function replaces the table needles in a query string with the actual table prefix.
  205.      *
  206.      * @param  string     The SQL query string
  207.      * @return string    The SQL query string
  208.      */
  209.     public function replaceTableNeedle$sql );
  210.  
  211.     /**
  212.      * Safely quotes a value for an SQL statement.
  213.      *
  214.      * If an array is passed as the value, the array values are quoted
  215.      * and then returned as a comma-separated string; this is useful
  216.      * for generating IN() lists.
  217.      *
  218.      * @param   mixed The value to quote.
  219.      * @return string An SQL-safe quoted value (or a string of separated-
  220.      *                 and-quoted values).
  221.      */
  222.     public function quoteValue($value);
  223.  
  224.     /**
  225.      * Quotes a single identifier name (table, table alias, table column,
  226.      * index, sequence).  Ignores empty values.
  227.      *
  228.      * This function requires all SQL statements, operators and functions to be
  229.      * uppercased.
  230.      *
  231.      * @param string|arrayThe identifier name to quote.  If an array, quotes
  232.      *                       each element in the array as an identifier name.
  233.      * @return string|arrayThe quoted identifier name (or array of names).
  234.      */
  235.     public function quoteName($spec);
  236. }

Documentation generated on Sun, 19 May 2013 03:03:58 +0200 by phpDocumentor 1.4.3