Source for file dibi.php
Documentation is available at dibi.php
- 1: <?php
- 3: /**
- 4: * dibi - tiny'n'smart database abstraction layer
- 5: * ----------------------------------------------
- 6: *
- 7: * Copyright (c) 2005, 2010 David Grudl (http://davidgrudl.com)
- 8: *
- 9: * This source file is subject to the "dibi license" that is bundled
- 10: * with this package in the file license.txt, and/or GPL license.
- 11: *
- 12: * For more information please see http://dibiphp.com
- 13: *
- 18: */
- 21: /**
- 22: * Check PHP configuration.
- 23: */
- 26: }
- 32: /**
- 33: * Compatibility with Nette
- 34: */
- 40: }
- 43: /**#@+ @package exceptions */
- 50: /**#@-*/
- 53: }
- 60: {
- 66: 5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point', // PREG_BAD_UTF8_OFFSET_ERROR
- 69: parent::__construct(str_replace('%msg', isset($messages[$code]) ? $messages[$code] : 'Unknown error', $message), $code);
- 70: }
- 71: }
- 75: /**
- 77: */
- 79: {
- 81: {
- 83: }
- 84: }
- 88: // dibi libraries
- 107: /**
- 108: * Interface for database drivers.
- 109: *
- 110: * This class is static container class for creating DB objects and
- 111: * store connections info.
- 112: *
- 115: */
- 117: {
- 118: /**#@+
- 119: * dibi data type
- 120: */
- 130: /**#@-*/
- 132: /**#@+
- 133: * @deprecated column types
- 134: */
- 143: /**#@-*/
- 145: /**#@+
- 146: * dibi version
- 147: */
- 150: /**#@-*/
- 183: /**
- 184: * Static class - cannot be instantiated.
- 185: */
- 187: {
- 189: }
- 193: /********************* connections handling ****************d*g**/
- 197: /**
- 198: * Creates a new DibiConnection object and connects it to specified database.
- 203: */
- 205: {
- 207: }
- 211: /**
- 212: * Disconnects from database (doesn't destroy DibiConnection object).
- 214: */
- 216: {
- 218: }
- 222: /**
- 223: * Returns TRUE when connection was established.
- 225: */
- 227: {
- 229: }
- 233: /**
- 234: * Retrieve active connection.
- 238: */
- 240: {
- 244: }
- 247: }
- 251: }
- 254: }
- 258: /**
- 259: * Change active connection.
- 263: */
- 265: {
- 267: }
- 271: /**
- 272: * Retrieve active connection profiler.
- 275: */
- 277: {
- 279: }
- 283: /********************* monostate for active connection ****************d*g**/
- 287: /**
- 288: * Generates and executes SQL query - Monostate for DibiConnection::query().
- 292: */
- 294: {
- 297: }
- 301: /**
- 302: * Executes the SQL query - Monostate for DibiConnection::nativeQuery().
- 305: */
- 307: {
- 309: }
- 313: /**
- 314: * Generates and prints SQL query - Monostate for DibiConnection::test().
- 317: */
- 319: {
- 322: }
- 326: /**
- 327: * Generates and returns SQL query as DibiDataSource - Monostate for DibiConnection::test().
- 330: */
- 332: {
- 335: }
- 339: /**
- 340: * Executes SQL query and fetch result - Monostate for DibiConnection::query() & fetch().
- 344: */
- 346: {
- 349: }
- 353: /**
- 354: * Executes SQL query and fetch results - Monostate for DibiConnection::query() & fetchAll().
- 358: */
- 360: {
- 363: }
- 367: /**
- 368: * Executes SQL query and fetch first column - Monostate for DibiConnection::query() & fetchSingle().
- 372: */
- 374: {
- 377: }
- 381: /**
- 382: * Executes SQL query and fetch pairs - Monostate for DibiConnection::query() & fetchPairs().
- 386: */
- 388: {
- 391: }
- 395: /**
- 396: * Gets the number of affected rows.
- 397: * Monostate for DibiConnection::getAffectedRows()
- 400: */
- 402: {
- 404: }
- 408: /**
- 409: * Gets the number of affected rows. Alias for getAffectedRows().
- 412: */
- 414: {
- 416: }
- 420: /**
- 421: * Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- 422: * Monostate for DibiConnection::getInsertId()
- 426: */
- 428: {
- 430: }
- 434: /**
- 435: * Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
- 439: */
- 441: {
- 443: }
- 447: /**
- 448: * Begins a transaction - Monostate for DibiConnection::begin().
- 452: */
- 454: {
- 456: }
- 460: /**
- 461: * Commits statements in a transaction - Monostate for DibiConnection::commit($savepoint = NULL).
- 465: */
- 467: {
- 469: }
- 473: /**
- 474: * Rollback changes in a transaction - Monostate for DibiConnection::rollback().
- 478: */
- 480: {
- 482: }
- 486: /**
- 487: * Gets a information about the current database - Monostate for DibiConnection::getDatabaseInfo().
- 489: */
- 491: {
- 493: }
- 497: /**
- 498: * Import SQL dump from file - extreme fast!
- 501: */
- 503: {
- 505: }
- 509: /**
- 510: * Replacement for majority of dibi::methods() in future.
- 511: */
- 513: {
- 514: //if ($name = 'select', 'update', ...') {
- 515: // return self::command()->$name($args);
- 516: //}
- 518: }
- 522: /********************* fluent SQL builders ****************d*g**/
- 526: /**
- 528: */
- 530: {
- 532: }
- 536: /**
- 539: */
- 541: {
- 544: }
- 548: /**
- 552: */
- 554: {
- 556: }
- 560: /**
- 564: */
- 566: {
- 568: }
- 572: /**
- 575: */
- 577: {
- 579: }
- 583: /********************* data types ****************d*g**/
- 587: /**
- 589: */
- 591: {
- 593: }
- 597: /**
- 599: */
- 601: {
- 603: }
- 607: /********************* substitutions ****************d*g**/
- 611: /**
- 612: * Create a new substitution pair for indentifiers.
- 616: */
- 618: {
- 620: }
- 624: /**
- 625: * Remove substitution pair.
- 628: */
- 630: {
- 635: }
- 636: }
- 640: /**
- 641: * Sets substitution fallback handler.
- 644: */
- 646: {
- 648: }
- 652: /**
- 653: * Default substitution fallback handler.
- 656: */
- 658: {
- 660: }
- 664: /********************* misc tools ****************d*g**/
- 668: /**
- 669: * Prints out a syntax highlighted version of the SQL command or DibiResult.
- 673: */
- 675: {
- 683: static $keywords1 = 'SELECT|UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|DELETE|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE';
- 684: static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|TRUE|FALSE';
- 686: // insert new lines
- 690: // reduce spaces
- 699: // syntax highlight
- 701: $sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])($keywords1)(?=[\\s,)])|(?<=[\\s,(=])($keywords2)(?=[\\s,)=])#is", array('dibi', 'highlightCallback'), $sql);
- 703: }
- 704: }
- 710: }
- 711: }
- 716: {
- 728: }
- 730: }
- 734: // static constructor