Packages

  • dibi
    • drivers
    • nette
    • reflection
  • None
  • PHP

Classes

  • dibi
  • DibiConnection
  • DibiDataSource
  • DibiDateTime
  • DibiEvent
  • DibiFileLogger
  • DibiFirePhpLogger
  • DibiFluent
  • DibiObject
  • DibiResult
  • DibiResultIterator
  • DibiRow
  • DibiTranslator

Interfaces

  • IDataSource
  • IDibiDriver
  • IDibiReflector
  • IDibiResultDriver

Exceptions

  • DibiDriverException
  • DibiException
  • DibiNotImplementedException
  • DibiNotSupportedException
  • DibiPcreException
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the "dibi" - smart database abstraction layer.
  5:  *
  6:  * Copyright (c) 2005 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  */
 11: 
 12: 
 13: 
 14: /**
 15:  * Provides an interface between a dataset and data-aware components.
 16:  * @package    dibi
 17:  */
 18: interface IDataSource extends Countable, IteratorAggregate
 19: {
 20:     //function IteratorAggregate::getIterator();
 21:     //function Countable::count();
 22: }
 23: 
 24: 
 25: 
 26: /**
 27:  * dibi driver interface.
 28:  * @package    dibi
 29:  */
 30: interface IDibiDriver
 31: {
 32: 
 33:     /**
 34:      * Connects to a database.
 35:      * @param  array
 36:      * @return void
 37:      * @throws DibiException
 38:      */
 39:     function connect(array &$config);
 40: 
 41:     /**
 42:      * Disconnects from a database.
 43:      * @return void
 44:      * @throws DibiException
 45:      */
 46:     function disconnect();
 47: 
 48:     /**
 49:      * Internal: Executes the SQL query.
 50:      * @param  string      SQL statement.
 51:      * @return IDibiResultDriver|NULL
 52:      * @throws DibiDriverException
 53:      */
 54:     function query($sql);
 55: 
 56:     /**
 57:      * Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
 58:      * @return int|FALSE  number of rows or FALSE on error
 59:      */
 60:     function getAffectedRows();
 61: 
 62:     /**
 63:      * Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
 64:      * @return int|FALSE  int on success or FALSE on failure
 65:      */
 66:     function getInsertId($sequence);
 67: 
 68:     /**
 69:      * Begins a transaction (if supported).
 70:      * @param  string  optional savepoint name
 71:      * @return void
 72:      * @throws DibiDriverException
 73:      */
 74:     function begin($savepoint = NULL);
 75: 
 76:     /**
 77:      * Commits statements in a transaction.
 78:      * @param  string  optional savepoint name
 79:      * @return void
 80:      * @throws DibiDriverException
 81:      */
 82:     function commit($savepoint = NULL);
 83: 
 84:     /**
 85:      * Rollback changes in a transaction.
 86:      * @param  string  optional savepoint name
 87:      * @return void
 88:      * @throws DibiDriverException
 89:      */
 90:     function rollback($savepoint = NULL);
 91: 
 92:     /**
 93:      * Returns the connection resource.
 94:      * @return mixed
 95:      */
 96:     function getResource();
 97: 
 98:     /**
 99:      * Returns the connection reflector.
100:      * @return IDibiReflector
101:      */
102:     function getReflector();
103: 
104:     /**
105:      * Encodes data for use in a SQL statement.
106:      * @param  string    value
107:      * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
108:      * @return string    encoded value
109:      * @throws InvalidArgumentException
110:      */
111:     function escape($value, $type);
112: 
113:     /**
114:      * Encodes string for use in a LIKE statement.
115:      * @param  string
116:      * @param  int
117:      * @return string
118:      */
119:     function escapeLike($value, $pos);
120: 
121:     /**
122:      * Injects LIMIT/OFFSET to the SQL query.
123:      * @param  string &$sql  The SQL query that will be modified.
124:      * @param  int $limit
125:      * @param  int $offset
126:      * @return void
127:      */
128:     function applyLimit(&$sql, $limit, $offset);
129: 
130: }
131: 
132: 
133: 
134: 
135: 
136: /**
137:  * dibi result set driver interface.
138:  * @package    dibi
139:  */
140: interface IDibiResultDriver
141: {
142: 
143:     /**
144:      * Returns the number of rows in a result set.
145:      * @return int
146:      */
147:     function getRowCount();
148: 
149:     /**
150:      * Moves cursor position without fetching row.
151:      * @param  int      the 0-based cursor pos to seek to
152:      * @return boolean  TRUE on success, FALSE if unable to seek to specified record
153:      * @throws DibiException
154:      */
155:     function seek($row);
156: 
157:     /**
158:      * Fetches the row at current position and moves the internal cursor to the next position.
159:      * @param  bool     TRUE for associative array, FALSE for numeric
160:      * @return array    array on success, nonarray if no next record
161:      * @internal
162:      */
163:     function fetch($type);
164: 
165:     /**
166:      * Frees the resources allocated for this result set.
167:      * @param  resource  result set resource
168:      * @return void
169:      */
170:     function free();
171: 
172:     /**
173:      * Returns metadata for all columns in a result set.
174:      * @return array of {name, nativetype [, table, fullname, (int) size, (bool) nullable, (mixed) default, (bool) autoincrement, (array) vendor ]}
175:      */
176:     function getResultColumns();
177: 
178:     /**
179:      * Returns the result set resource.
180:      * @return mixed
181:      */
182:     function getResultResource();
183: 
184:     /**
185:      * Decodes data from result set.
186:      * @param  string    value
187:      * @param  string    type (dibi::BINARY)
188:      * @return string    decoded value
189:      * @throws InvalidArgumentException
190:      */
191:     function unescape($value, $type);
192: 
193: }
194: 
195: 
196: 
197: 
198: 
199: /**
200:  * dibi driver reflection.
201:  *
202:  * @author     David Grudl
203:  * @package    dibi
204:  */
205: interface IDibiReflector
206: {
207: 
208:     /**
209:      * Returns list of tables.
210:      * @return array of {name [, (bool) view ]}
211:      */
212:     function getTables();
213: 
214:     /**
215:      * Returns metadata for all columns in a table.
216:      * @param  string
217:      * @return array of {name, nativetype [, table, fullname, (int) size, (bool) nullable, (mixed) default, (bool) autoincrement, (array) vendor ]}
218:      */
219:     function getColumns($table);
220: 
221:     /**
222:      * Returns metadata for all indexes in a table.
223:      * @param  string
224:      * @return array of {name, (array of names) columns [, (bool) unique, (bool) primary ]}
225:      */
226:     function getIndexes($table);
227: 
228:     /**
229:      * Returns metadata for all foreign keys in a table.
230:      * @param  string
231:      * @return array
232:      */
233:     function getForeignKeys($table);
234: 
235: }
236: 
dibi API documentation API documentation generated by ApiGen 2.3.0