2007-11-12 06:43:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dibi - tiny'n'smart database abstraction layer
|
|
|
|
* ----------------------------------------------
|
|
|
|
*
|
2008-01-02 05:25:21 +00:00
|
|
|
* Copyright (c) 2005, 2008 David Grudl aka -dgx- (http://www.dgx.cz)
|
2007-11-12 06:43:09 +00:00
|
|
|
*
|
|
|
|
* This source file is subject to the "dibi license" that is bundled
|
|
|
|
* with this package in the file license.txt.
|
|
|
|
*
|
2007-12-05 09:27:55 +00:00
|
|
|
* For more information please see http://dibiphp.com/
|
2007-11-12 06:43:09 +00:00
|
|
|
*
|
2008-01-02 05:25:21 +00:00
|
|
|
* @copyright Copyright (c) 2005, 2008 David Grudl
|
2007-12-05 09:27:55 +00:00
|
|
|
* @license http://dibiphp.com/license dibi license
|
|
|
|
* @link http://dibiphp.com/
|
2007-11-12 06:43:09 +00:00
|
|
|
* @package dibi
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-15 03:43:03 +00:00
|
|
|
/**
|
|
|
|
* Interface for user variable, used for generating SQL
|
|
|
|
* @package dibi
|
|
|
|
*/
|
|
|
|
interface IDibiVariable
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Format for SQL
|
|
|
|
*
|
|
|
|
* @param object destination IDibiDriver
|
|
|
|
* @param string optional modifier
|
|
|
|
* @return string SQL code
|
|
|
|
*/
|
|
|
|
public function toSql(IDibiDriver $driver, $modifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-18 02:57:43 +00:00
|
|
|
/**
|
|
|
|
* Provides an interface between a dataset and data-aware components
|
|
|
|
* @package dibi
|
|
|
|
*/
|
|
|
|
interface IDataSource extends Countable, IteratorAggregate
|
|
|
|
{
|
|
|
|
//function IteratorAggregate::getIterator();
|
|
|
|
//function Countable::count();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-12 06:43:09 +00:00
|
|
|
/**
|
|
|
|
* dibi driver interface
|
|
|
|
*
|
|
|
|
* @author David Grudl
|
2008-01-02 05:25:21 +00:00
|
|
|
* @copyright Copyright (c) 2005, 2008 David Grudl
|
2007-11-12 06:43:09 +00:00
|
|
|
* @package dibi
|
|
|
|
* @version $Revision$ $Date$
|
|
|
|
*/
|
2008-01-15 03:43:03 +00:00
|
|
|
interface IDibiDriver
|
2007-11-12 06:43:09 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal: Connects to a database
|
|
|
|
*
|
|
|
|
* @param array
|
|
|
|
* @return void
|
|
|
|
* @throws DibiException
|
|
|
|
*/
|
|
|
|
function connect(array &$config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal: Disconnects from a database
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @throws DibiException
|
|
|
|
*/
|
|
|
|
function disconnect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal: Executes the SQL query
|
|
|
|
*
|
2007-12-11 07:28:55 +00:00
|
|
|
* @param string SQL statement.
|
2007-11-12 06:43:09 +00:00
|
|
|
* @return bool have resultset?
|
2007-11-17 09:37:55 +00:00
|
|
|
* @throws DibiDriverException
|
2007-11-12 06:43:09 +00:00
|
|
|
*/
|
|
|
|
function query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
|
|
|
|
*
|
2007-11-23 23:27:14 +00:00
|
|
|
* @return int|FALSE number of rows or FALSE on error
|
2007-11-12 06:43:09 +00:00
|
|
|
*/
|
|
|
|
function affectedRows();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
|
|
|
|
*
|
|
|
|
* @return int|FALSE int on success or FALSE on failure
|
|
|
|
*/
|
|
|
|
function insertId($sequence);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Begins a transaction (if supported).
|
|
|
|
* @return void
|
2007-11-23 23:27:14 +00:00
|
|
|
* @throws DibiDriverException
|
2007-11-12 06:43:09 +00:00
|
|
|
*/
|
|
|
|
function begin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Commits statements in a transaction.
|
|
|
|
* @return void
|
2007-11-23 23:27:14 +00:00
|
|
|
* @throws DibiDriverException
|
2007-11-12 06:43:09 +00:00
|
|
|
*/
|
|
|
|
function commit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rollback changes in a transaction.
|
|
|
|
* @return void
|
2007-11-23 23:27:14 +00:00
|
|
|
* @throws DibiDriverException
|
2007-11-12 06:43:09 +00:00
|
|
|
*/
|
|
|
|
function rollback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Format to SQL command
|
|
|
|
*
|
2007-12-11 07:28:55 +00:00
|
|
|
* @param string value
|
|
|
|
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
|
2007-11-12 06:43:09 +00:00
|
|
|
* @return string formatted value
|
|
|
|
*/
|
|
|
|
function format($value, $type);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Injects LIMIT/OFFSET to the SQL query
|
|
|
|
*
|
2007-12-11 07:28:55 +00:00
|
|
|
* @param string &$sql The SQL query that will be modified.
|
|
|
|
* @param int $limit
|
|
|
|
* @param int $offset
|
2007-11-12 06:43:09 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function applyLimit(&$sql, $limit, $offset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of rows in a result set
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
function rowCount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves cursor position without fetching row
|
|
|
|
*
|
2007-11-13 01:51:44 +00:00
|
|
|
* @param int the 0-based cursor pos to seek to
|
|
|
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
2007-11-12 06:43:09 +00:00
|
|
|
* @throws DibiException
|
|
|
|
*/
|
|
|
|
function seek($row);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches the row at current position and moves the internal cursor to the next position
|
|
|
|
* internal usage only
|
|
|
|
*
|
2007-11-30 10:12:45 +00:00
|
|
|
* @param bool TRUE for associative array, FALSE for numeric
|
|
|
|
* @return array array on success, nonarray if no next record
|
2007-11-12 06:43:09 +00:00
|
|
|
*/
|
2007-11-30 10:12:45 +00:00
|
|
|
function fetch($type);
|
2007-11-12 06:43:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frees the resources allocated for this result set
|
|
|
|
*
|
|
|
|
* @param resource resultset resource
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function free();
|
|
|
|
|
|
|
|
|
2007-11-23 23:27:14 +00:00
|
|
|
|
2007-11-30 10:12:45 +00:00
|
|
|
/**
|
|
|
|
* Returns metadata for all columns in a result set
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
* @throws DibiException
|
|
|
|
*/
|
|
|
|
function getColumnsMeta();
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-12 06:43:09 +00:00
|
|
|
/**
|
|
|
|
* Returns the connection resource
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
function getResource();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the resultset resource
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
function getResultResource();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a information of the current database.
|
|
|
|
*
|
|
|
|
* @return DibiReflection
|
|
|
|
*/
|
|
|
|
function getDibiReflection();
|
|
|
|
|
|
|
|
}
|