diff --git a/dibi/dibi.php b/dibi/dibi.php index 001ffa47..4ee601e1 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -196,6 +196,7 @@ class dibi } + /** * Retrieve active connection * @@ -439,6 +440,7 @@ class dibi } + /** * Remove substitution pair * @param string from @@ -450,6 +452,7 @@ class dibi } + /** * Process substitutions in string * @param string @@ -462,6 +465,7 @@ class dibi } + /** * Error logging * EXPERIMENTAL diff --git a/dibi/drivers/mssql.php b/dibi/drivers/mssql.php index b9c14951..ea92b85c 100644 --- a/dibi/drivers/mssql.php +++ b/dibi/drivers/mssql.php @@ -74,7 +74,6 @@ class DibiMSSqlDriver extends DibiDriver - public function nativeQuery($sql) { $this->affectedRows = FALSE; @@ -93,36 +92,42 @@ class DibiMSSqlDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return FALSE; } + public function begin() { return mssql_query('BEGIN TRANSACTION', $this->getConnection()); } + public function commit() { return mssql_query('COMMIT', $this->getConnection()); } + public function rollback() { return mssql_query('ROLLBACK', $this->getConnection()); } + public function errorInfo() { return array( @@ -132,6 +137,7 @@ class DibiMSSqlDriver extends DibiDriver } + public function escape($value, $appendQuotes = TRUE) { $value = str_replace("'", "''", $value); @@ -141,18 +147,21 @@ class DibiMSSqlDriver extends DibiDriver } + public function delimite($value) { return '[' . str_replace('.', '].[', $value) . ']'; } + public function getMetaData() { trigger_error('Meta is not implemented yet.', E_USER_WARNING); } + /** * @see DibiDriver::applyLimit() */ @@ -187,30 +196,35 @@ class DibiMSSqlResult extends DibiResult } + public function rowCount() { return mssql_num_rows($this->resource); } + protected function doFetch() { return mssql_fetch_assoc($this->resource); } + public function seek($row) { return mssql_data_seek($this->resource, $row); } + protected function free() { mssql_free_result($this->resource); } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index 4e0c67f5..5a821db7 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -107,7 +107,6 @@ class DibiMySqlDriver extends DibiDriver - public function nativeQuery($sql) { $this->insertId = $this->affectedRows = FALSE; @@ -129,36 +128,42 @@ class DibiMySqlDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return $this->insertId; } + public function begin() { return mysql_query('BEGIN', $this->getConnection()); } + public function commit() { return mysql_query('COMMIT', $this->getConnection()); } + public function rollback() { return mysql_query('ROLLBACK', $this->getConnection()); } + public function errorInfo() { $connection = $this->getConnection(); @@ -169,6 +174,7 @@ class DibiMySqlDriver extends DibiDriver } + public function escape($value, $appendQuotes = TRUE) { $connection = $this->getConnection(); @@ -178,18 +184,21 @@ class DibiMySqlDriver extends DibiDriver } + public function delimite($value) { return '`' . str_replace('.', '`.`', $value) . '`'; } + public function getMetaData() { trigger_error('Meta is not implemented yet.', E_USER_WARNING); } + /** * @see DibiDriver::applyLimit() */ @@ -224,30 +233,35 @@ class DibiMySqlResult extends DibiResult } + public function rowCount() { return mysql_num_rows($this->resource); } + protected function doFetch() { return mysql_fetch_assoc($this->resource); } + public function seek($row) { return mysql_data_seek($this->resource, $row); } + protected function free() { mysql_free_result($this->resource); } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/drivers/mysqli.php b/dibi/drivers/mysqli.php index 48311497..284c8298 100644 --- a/dibi/drivers/mysqli.php +++ b/dibi/drivers/mysqli.php @@ -101,24 +101,28 @@ class DibiMySqliDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return $this->insertId; } + public function begin() { return mysqli_autocommit($this->getConnection(), FALSE); } + public function commit() { $connection = $this->getConnection(); @@ -128,6 +132,7 @@ class DibiMySqliDriver extends DibiDriver } + public function rollback() { $connection = $this->getConnection(); @@ -137,6 +142,7 @@ class DibiMySqliDriver extends DibiDriver } + public function errorInfo() { $connection = $this->getConnection(); @@ -148,7 +154,6 @@ class DibiMySqliDriver extends DibiDriver - public function escape($value, $appendQuotes = TRUE) { $connection = $this->getConnection(); @@ -158,6 +163,7 @@ class DibiMySqliDriver extends DibiDriver } + public function delimite($value) { return '`' . str_replace('.', '`.`', $value) . '`'; @@ -171,6 +177,7 @@ class DibiMySqliDriver extends DibiDriver } + /** * @see DibiDriver::applyLimit() */ @@ -205,30 +212,35 @@ class DibiMySqliResult extends DibiResult } + public function rowCount() { return mysqli_num_rows($this->resource); } + protected function doFetch() { return mysqli_fetch_assoc($this->resource); } + public function seek($row) { return mysqli_data_seek($this->resource, $row); } + protected function free() { mysqli_free_result($this->resource); } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/drivers/odbc.php b/dibi/drivers/odbc.php index 32e46543..be9c60ba 100644 --- a/dibi/drivers/odbc.php +++ b/dibi/drivers/odbc.php @@ -102,24 +102,28 @@ class DibiOdbcDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return FALSE; } + public function begin() { return odbc_autocommit($this->getConnection(), FALSE); } + public function commit() { $connection = $this->getConnection(); @@ -129,6 +133,7 @@ class DibiOdbcDriver extends DibiDriver } + public function rollback() { $connection = $this->getConnection(); @@ -138,6 +143,7 @@ class DibiOdbcDriver extends DibiDriver } + public function errorInfo() { $connection = $this->getConnection(); @@ -158,18 +164,21 @@ class DibiOdbcDriver extends DibiDriver } + public function delimite($value) { return '[' . str_replace('.', '].[', $value) . ']'; } + public function getMetaData() { trigger_error('Meta is not implemented yet.', E_USER_WARNING); } + /** * @see DibiDriver::applyLimit() */ @@ -203,6 +212,7 @@ class DibiOdbcResult extends DibiResult } + public function rowCount() { // will return -1 with many drivers :-( @@ -210,24 +220,28 @@ class DibiOdbcResult extends DibiResult } + protected function doFetch() { return odbc_fetch_array($this->resource, $this->row++); } + public function seek($row) { $this->row = $row; } + protected function free() { odbc_free_result($this->resource); } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/drivers/pdo.php b/dibi/drivers/pdo.php index 5818f7c8..95cebc56 100644 --- a/dibi/drivers/pdo.php +++ b/dibi/drivers/pdo.php @@ -77,36 +77,42 @@ class DibiPdoDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return $this->getConnection()->lastInsertId(); } + public function begin() { return $this->getConnection()->beginTransaction(); } + public function commit() { return $this->getConnection()->commit(); } + public function rollback() { return $this->getConnection()->rollBack(); } + public function errorInfo() { $error = $this->getConnection()->errorInfo(); @@ -118,6 +124,7 @@ class DibiPdoDriver extends DibiDriver } + public function escape($value, $appendQuotes = TRUE) { if (!$appendQuotes) { @@ -128,6 +135,7 @@ class DibiPdoDriver extends DibiDriver } + public function delimite($value) { // quoting is not supported by PDO @@ -175,29 +183,34 @@ class DibiPdoResult extends DibiResult } + public function rowCount() { return $this->resource->rowCount(); } + protected function doFetch() { return $this->resource->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT, $this->row++); } + public function seek($row) { $this->row = $row; } + protected function free() { } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index 22258614..f21681fc 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -96,36 +96,42 @@ class DibiPostgreDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return FALSE; } + public function begin() { return pg_query($this->getConnection(), 'BEGIN'); } + public function commit() { return pg_query($this->getConnection(), 'COMMIT'); } + public function rollback() { return pg_query($this->getConnection(), 'ROLLBACK'); } + public function errorInfo() { return array( @@ -135,6 +141,7 @@ class DibiPostgreDriver extends DibiDriver } + public function escape($value, $appendQuotes = TRUE) { return $appendQuotes @@ -143,6 +150,7 @@ class DibiPostgreDriver extends DibiDriver } + public function delimite($value) { return $value; @@ -191,30 +199,35 @@ class DibiPostgreResult extends DibiResult } + public function rowCount() { return pg_num_rows($this->resource); } + protected function doFetch() { return pg_fetch_array($this->resource, NULL, PGSQL_ASSOC); } + public function seek($row) { return pg_result_seek($this->resource, $row); } + protected function free() { pg_free_result($this->resource); } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/drivers/sqlite.php b/dibi/drivers/sqlite.php index f6078d29..a5ea1196 100644 --- a/dibi/drivers/sqlite.php +++ b/dibi/drivers/sqlite.php @@ -98,36 +98,42 @@ class DibiSqliteDriver extends DibiDriver } + public function affectedRows() { return $this->affectedRows; } + public function insertId() { return $this->insertId; } + public function begin() { return sqlite_query($this->getConnection(), 'BEGIN'); } + public function commit() { return sqlite_query($this->getConnection(), 'COMMIT'); } + public function rollback() { return sqlite_query($this->getConnection(), 'ROLLBACK'); } + public function errorInfo() { $code = sqlite_last_error($this->getConnection()); @@ -138,6 +144,7 @@ class DibiSqliteDriver extends DibiDriver } + public function escape($value, $appendQuotes = TRUE) { return $appendQuotes @@ -146,6 +153,7 @@ class DibiSqliteDriver extends DibiDriver } + public function delimite($value) { return '[' . str_replace('.', '].[', $value) . ']'; @@ -190,29 +198,34 @@ class DibiSqliteResult extends DibiResult } + public function rowCount() { return sqlite_num_rows($this->resource); } + protected function doFetch() { return sqlite_fetch_array($this->resource, SQLITE_ASSOC); } + public function seek($row) { return sqlite_seek($this->resource, $row); } + protected function free() { } + /** this is experimental */ protected function buildMeta() { diff --git a/dibi/libs/exception.php b/dibi/libs/exception.php index 0f3aaa7f..e2507bd1 100644 --- a/dibi/libs/exception.php +++ b/dibi/libs/exception.php @@ -49,6 +49,7 @@ class DibiException extends Exception } + public function __toString() { $s = parent::__toString(); diff --git a/dibi/libs/translator.php b/dibi/libs/translator.php index 5f1c7f62..0737eea3 100644 --- a/dibi/libs/translator.php +++ b/dibi/libs/translator.php @@ -137,7 +137,6 @@ final class DibiTranslator - private function formatValue($value, $modifier) { // array processing (with or without modifier) @@ -287,7 +286,6 @@ final class DibiTranslator - /** * PREG callback for @see self::formatValue() * @param array