diff --git a/dibi/dibi.php b/dibi/dibi.php index f3b7125f..a119cc99 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -12,7 +12,7 @@ * @license GNU GENERAL PUBLIC LICENSE version 2 * @package dibi * @category Database - * @version 0.7g (Revision: $WCREV$, Date: $WCDATE$) + * @version 0.7h (Revision: $WCREV$, Date: $WCDATE$) */ @@ -26,7 +26,7 @@ */ -define('DIBI', '0.7g (Revision: $WCREV$, Date: $WCDATE$)'); +define('DIBI', '0.7h (Revision: $WCREV$, Date: $WCDATE$)'); if (version_compare(PHP_VERSION , '5.0.3', '<')) @@ -153,7 +153,7 @@ class dibi * @return void * @throw DibiException */ - static public function connect($config, $name='1') + static public function connect($config, $name=0) { // DSN string if (is_string($config)) diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index c6d94688..b6fc0ebc 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -63,7 +63,7 @@ class DibiMySqlDriver extends DibiDriver $php_errormsg = ''; if (empty($config['persistent'])) - $conn = @mysql_connect($host, $config['username'], $config['password']); + $conn = @mysql_connect($host, $config['username'], $config['password'], TRUE); else $conn = @mysql_pconnect($host, $config['username'], $config['password']); @@ -159,7 +159,7 @@ class DibiMySqlDriver extends DibiDriver } - public function escape($value, $appendQuotes = FALSE) + public function escape($value, $appendQuotes=TRUE) { return $appendQuotes ? "'" . mysql_real_escape_string($value, $this->conn) . "'" @@ -167,7 +167,7 @@ class DibiMySqlDriver extends DibiDriver } - public function quoteName($value) + public function delimite($value) { return '`' . str_replace('.', '`.`', $value) . '`'; } diff --git a/dibi/drivers/mysqli.php b/dibi/drivers/mysqli.php index c5ab96a2..2ad41d03 100644 --- a/dibi/drivers/mysqli.php +++ b/dibi/drivers/mysqli.php @@ -133,7 +133,7 @@ class DibiMySqliDriver extends DibiDriver - public function escape($value, $appendQuotes = FALSE) + public function escape($value, $appendQuotes=TRUE) { return $appendQuotes ? "'" . mysqli_real_escape_string($this->conn, $value) . "'" @@ -141,7 +141,7 @@ class DibiMySqliDriver extends DibiDriver } - public function quoteName($value) + public function delimite($value) { return '`' . str_replace('.', '`.`', $value) . '`'; } diff --git a/dibi/drivers/odbc.php b/dibi/drivers/odbc.php index cf4427b3..342b682d 100644 --- a/dibi/drivers/odbc.php +++ b/dibi/drivers/odbc.php @@ -133,7 +133,7 @@ class DibiOdbcDriver extends DibiDriver - public function escape($value, $appendQuotes = FALSE) + public function escape($value, $appendQuotes=TRUE) { $value = str_replace("'", "''", $value); return $appendQuotes @@ -142,7 +142,7 @@ class DibiOdbcDriver extends DibiDriver } - public function quoteName($value) + public function delimite($value) { return '[' . str_replace('.', '].[', $value) . ']'; } diff --git a/dibi/drivers/pdo.php b/dibi/drivers/pdo.php index fd5d1834..2bfb08ff 100644 --- a/dibi/drivers/pdo.php +++ b/dibi/drivers/pdo.php @@ -112,7 +112,7 @@ class DibiPdoDriver extends DibiDriver } - public function escape($value, $appendQuotes = FALSE) + public function escape($value, $appendQuotes=TRUE) { if (!$appendQuotes) { trigger_error('dibi: escaping without qoutes is not supported by PDO', E_USER_WARNING); @@ -122,7 +122,7 @@ class DibiPdoDriver extends DibiDriver } - public function quoteName($value) + public function delimite($value) { // quoting is not supported by PDO return $value; diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index 555a8abb..fb1bdf30 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -123,7 +123,7 @@ class DibiPostgreDriver extends DibiDriver } - public function escape($value, $appendQuotes = FALSE) + public function escape($value, $appendQuotes=TRUE) { return $appendQuotes ? "'" . pg_escape_string($value) . "'" @@ -131,7 +131,7 @@ class DibiPostgreDriver extends DibiDriver } - public function quoteName($value) + public function delimite($value) { return $value; } diff --git a/dibi/drivers/sqlite.php b/dibi/drivers/sqlite.php index dfd956be..4d62d672 100644 --- a/dibi/drivers/sqlite.php +++ b/dibi/drivers/sqlite.php @@ -125,7 +125,7 @@ class DibiSqliteDriver extends DibiDriver } - public function escape($value, $appendQuotes = FALSE) + public function escape($value, $appendQuotes=TRUE) { return $appendQuotes ? "'" . sqlite_escape_string($value) . "'" @@ -133,7 +133,7 @@ class DibiSqliteDriver extends DibiDriver } - public function quoteName($value) + public function delimite($value) { return '[' . $value . ']'; } diff --git a/dibi/libs/driver.php b/dibi/libs/driver.php index bbfe7167..695d1119 100644 --- a/dibi/libs/driver.php +++ b/dibi/libs/driver.php @@ -197,16 +197,16 @@ abstract class DibiDriver * @param bool quote string? * @return string escaped and optionally quoted string */ - abstract public function escape($value, $appendQuotes = FALSE); + abstract public function escape($value, $appendQuotes=TRUE); /** - * Quotes SQL identifier (table's or column's name, etc.) + * Delimites identifier (table's or column's name, etc.) * @param string identifier - * @return string quoted identifier + * @return string delimited identifier */ - abstract public function quoteName($value); + abstract public function delimite($value); diff --git a/dibi/libs/translator.php b/dibi/libs/translator.php index 93438232..ac74982b 100644 --- a/dibi/libs/translator.php +++ b/dibi/libs/translator.php @@ -140,7 +140,7 @@ class DibiTranslator $pair = explode('%', $k, 2); // generate array - $vx[] = $this->quote($pair[0]) . '=' + $vx[] = $this->delimite($pair[0]) . '=' . $this->formatValue($v, isset($pair[1]) ? $pair[1] : FALSE); } return implode(', ', $vx); @@ -152,7 +152,7 @@ class DibiTranslator $pair = explode('%', $k, 2); // generate arrays - $kx[] = $this->quote($pair[0]); + $kx[] = $this->delimite($pair[0]); $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : FALSE); } return '(' . implode(', ', $kx) . ') VALUES (' . implode(', ', $vx) . ')'; @@ -181,9 +181,9 @@ class DibiTranslator switch ($modifier) { case 's': // string - return $this->driver->escape($value, TRUE); + return $this->driver->escape($value); case 'sn': // string or NULL - return $value == '' ? 'NULL' : $this->driver->escape($value, TRUE); + return $value == '' ? 'NULL' : $this->driver->escape($value); case 'b': // boolean return $value ? $this->driver->formats['TRUE'] @@ -202,7 +202,7 @@ class DibiTranslator ? strtotime($value) : $value); case 'n': // identifier name - return $this->quote($value); + return $this->delimite($value); case 'sql':// preserve as SQL case 'p': // back compatibility $value = (string) $value; @@ -250,7 +250,7 @@ class DibiTranslator // without modifier procession if (is_string($value)) - return $this->driver->escape($value, TRUE); + return $this->driver->escape($value); if (is_int($value) || is_float($value)) return (string) $value; // something like -9E-005 is accepted by SQL @@ -326,16 +326,16 @@ class DibiTranslator if ($matches[1]) // SQL identifiers: `ident` - return $this->quote($matches[1]); + return $this->delimite($matches[1]); if ($matches[2]) // SQL identifiers: [ident] - return $this->quote($matches[2]); + return $this->delimite($matches[2]); if ($matches[3]) // SQL strings: '....' - return $this->driver->escape( str_replace("''", "'", $matches[4]), TRUE); + return $this->driver->escape( str_replace("''", "'", $matches[4])); if ($matches[5]) // SQL strings: "..." - return $this->driver->escape( str_replace('""', '"', $matches[6]), TRUE); + return $this->driver->escape( str_replace('""', '"', $matches[6])); if ($matches[9]) { // string quote @@ -349,13 +349,13 @@ class DibiTranslator /** - * Apply substitutions to indentifier and quotes it + * Apply substitutions to indentifier and delimites it * @param string indentifier * @return string */ - private function quote($value) + private function delimite($value) { - return $this->driver->quoteName( dibi::substitute($value) ); + return $this->driver->delimite( dibi::substitute($value) ); } diff --git a/version.txt b/version.txt index 327cd465..f0db3cbf 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ -Dibi version 0.7g +Dibi version 0.7h Revision: $WCREV$ Date: $WCDATE$