cvs: pear /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php sqlite.php /MDB2/MDB2/Driver/Datatype
Common.php fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php

From: Date: Sat, 14 Oct 2006 13:42:02 +0000
Subject: cvs: pear /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php sqlite.php /MDB2/MDB2/Driver/Datatype
Common.php fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42550@lists.php.net to get a copy of this message
lsmith Sat Oct 14 13:42:02 2006 UTC Modified files: /pear/MDB2/MDB2/Driver/Datatype Common.php fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php /pear/MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php sqlite.php Log: - handle quoted identifier and SQL comment in prepare parser - expanded definition of quote and escape characters - added support for scale in decimal field definition

http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/Common.php?r1=1.111&r2=1.112&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/Common.php diff -u pear/MDB2/MDB2/Driver/Datatype/Common.php:1.111 pear/MDB2/MDB2/Driver/Datatype/Common.php:1.112 --- pear/MDB2/MDB2/Driver/Datatype/Common.php:1.111 Tue Sep 26 13:37:25 2006 +++ pear/MDB2/MDB2/Driver/Datatype/Common.php Sat Oct 14 13:42:00 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.111 2006/09/26 13:37:25 quipo Exp $ +// $Id: Common.php,v 1.112 2006/10/14 13:42:00 lsmith Exp $ require_once 'MDB2/LOB.php'; @@ -1092,7 +1092,9 @@ 'type not defined: '.$type, __FUNCTION__); } $value = $this->{"_quote{$type}"}($value, $quote, $escape_wildcards); - if ($quote && $escape_wildcards && $db->escape_quotes !== $db->escape_pattern) { + if ($quote && $escape_wildcards && $db->string_quoting['escape_pattern'] + && $db->string_quoting['escape'] !== $db->string_quoting['escape_pattern'] + ) { $value.= $this->patternEscapeString(); } return $value; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/fbsql.php?r1=1.33&r2=1.34&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/fbsql.php diff -u pear/MDB2/MDB2/Driver/Datatype/fbsql.php:1.33 pear/MDB2/MDB2/Driver/Datatype/fbsql.php:1.34 --- pear/MDB2/MDB2/Driver/Datatype/fbsql.php:1.33 Thu Sep 14 14:47:26 2006 +++ pear/MDB2/MDB2/Driver/Datatype/fbsql.php Sat Oct 14 13:42:01 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.33 2006/09/14 14:47:26 lsmith Exp $ +// $Id: fbsql.php,v 1.34 2006/10/14 13:42:01 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -143,7 +143,8 @@ return 'FLOAT'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; } return ''; } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/ibase.php?r1=1.84&r2=1.85&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/ibase.php diff -u pear/MDB2/MDB2/Driver/Datatype/ibase.php:1.84 pear/MDB2/MDB2/Driver/Datatype/ibase.php:1.85 --- pear/MDB2/MDB2/Driver/Datatype/ibase.php:1.84 Tue Sep 26 13:37:25 2006 +++ pear/MDB2/MDB2/Driver/Datatype/ibase.php Sat Oct 14 13:42:01 2006 @@ -44,7 +44,7 @@ // | Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.84 2006/09/26 13:37:25 quipo Exp $ +// $Id: ibase.php,v 1.85 2006/10/14 13:42:01 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -175,7 +175,8 @@ return 'DOUBLE PRECISION'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; } return ''; } @@ -319,7 +320,7 @@ if (PEAR::isError($db)) { return $db; } - return " ESCAPE '". $db->escape_pattern ."'"; + return " ESCAPE '". $db->string_quoting['escape_pattern'] ."'"; } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/mssql.php?r1=1.46&r2=1.47&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mssql.php diff -u pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.46 pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.47 --- pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.46 Thu Sep 14 14:47:26 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mssql.php Sat Oct 14 13:42:01 2006 @@ -44,7 +44,7 @@ // | Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.46 2006/09/14 14:47:26 lsmith Exp $ +// $Id: mssql.php,v 1.47 2006/10/14 13:42:01 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -160,7 +160,8 @@ return 'FLOAT'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; } return ''; } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/mysql.php?r1=1.53&r2=1.54&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mysql.php diff -u pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.53 pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.54 --- pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.53 Tue Sep 26 13:37:25 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mysql.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.53 2006/09/26 13:37:25 quipo Exp $ +// $Id: mysql.php,v 1.54 2006/10/14 13:42:02 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -182,7 +182,8 @@ return 'DOUBLE'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; } return ''; } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/mysqli.php?r1=1.52&r2=1.53&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mysqli.php diff -u pear/MDB2/MDB2/Driver/Datatype/mysqli.php:1.52 pear/MDB2/MDB2/Driver/Datatype/mysqli.php:1.53 --- pear/MDB2/MDB2/Driver/Datatype/mysqli.php:1.52 Tue Sep 26 13:37:25 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mysqli.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.52 2006/09/26 13:37:25 quipo Exp $ +// $Id: mysqli.php,v 1.53 2006/10/14 13:42:02 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -182,7 +182,8 @@ return 'DOUBLE'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; } return ''; } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/oci8.php?r1=1.66&r2=1.67&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/oci8.php diff -u pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.66 pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.67 --- pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.66 Thu Sep 14 14:47:26 2006 +++ pear/MDB2/MDB2/Driver/Datatype/oci8.php Sat Oct 14 13:42:02 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.66 2006/09/14 14:47:26 lsmith Exp $ +// $Id: oci8.php,v 1.67 2006/10/14 13:42:02 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -137,7 +137,8 @@ case 'float': return 'NUMBER'; case 'decimal': - return 'NUMBER(*,'.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'NUMBER(*,'.$scale.')'; } } @@ -362,7 +363,7 @@ if (PEAR::isError($db)) { return $db; } - return " ESCAPE '".$db->escape_pattern."'"; + return " ESCAPE '". $db->string_quoting['escape_pattern'] ."'"; } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/pgsql.php?r1=1.75&r2=1.76&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/pgsql.php diff -u pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.75 pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.76 --- pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.75 Thu Sep 14 14:47:26 2006 +++ pear/MDB2/MDB2/Driver/Datatype/pgsql.php Sat Oct 14 13:42:02 2006 @@ -42,7 +42,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.75 2006/09/14 14:47:26 lsmith Exp $ +// $Id: pgsql.php,v 1.76 2006/10/14 13:42:02 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -166,7 +166,8 @@ return 'FLOAT8'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'NUMERIC('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'NUMERIC('.$length.','.$scale.')'; } } @@ -365,7 +366,7 @@ if (PEAR::isError($db)) { return $db; } - return ' ESCAPE '.$this->quote($db->escape_pattern); + return ' ESCAPE '.$this->quote($db->string_quoting['escape_pattern']); } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/sqlite.php?r1=1.59&r2=1.60&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/sqlite.php diff -u pear/MDB2/MDB2/Driver/Datatype/sqlite.php:1.59 pear/MDB2/MDB2/Driver/Datatype/sqlite.php:1.60 --- pear/MDB2/MDB2/Driver/Datatype/sqlite.php:1.59 Fri Aug 25 17:06:49 2006 +++ pear/MDB2/MDB2/Driver/Datatype/sqlite.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.59 2006/08/25 17:06:49 lsmith Exp $ +// $Id: sqlite.php,v 1.60 2006/10/14 13:42:02 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -146,7 +146,8 @@ ($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : ''); case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; } return ''; } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/fbsql.php?r1=1.123&r2=1.124&diff_format=u Index: pear/MDB2/MDB2/Driver/fbsql.php diff -u pear/MDB2/MDB2/Driver/fbsql.php:1.123 pear/MDB2/MDB2/Driver/fbsql.php:1.124 --- pear/MDB2/MDB2/Driver/fbsql.php:1.123 Sun Aug 20 09:48:43 2006 +++ pear/MDB2/MDB2/Driver/fbsql.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.123 2006/08/20 09:48:43 lsmith Exp $ +// $Id: fbsql.php,v 1.124 2006/10/14 13:42:02 lsmith Exp $ // /** @@ -57,10 +57,9 @@ class MDB2_Driver_fbsql extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "'"; - - var $escape_identifier = '"'; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => false); + var $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"'); // }}} // {{{ constructor http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/ibase.php?r1=1.190&r2=1.191&diff_format=u Index: pear/MDB2/MDB2/Driver/ibase.php diff -u pear/MDB2/MDB2/Driver/ibase.php:1.190 pear/MDB2/MDB2/Driver/ibase.php:1.191 --- pear/MDB2/MDB2/Driver/ibase.php:1.190 Sat Oct 14 10:27:41 2006 +++ pear/MDB2/MDB2/Driver/ibase.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.190 2006/10/14 10:27:41 quipo Exp $ +// $Id: ibase.php,v 1.191 2006/10/14 13:42:02 lsmith Exp $ /** * MDB2 FireBird/InterBase driver @@ -55,17 +55,15 @@ class MDB2_Driver_ibase extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "'"; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => '\\'); - var $escape_pattern = "\\"; - - var $escape_identifier = ''; + var $identifier_quoting = array('start' => '', 'end' => '', 'escape' => false); var $transaction_id = 0; var $query_parameters = array(); - var $query_parameter_values = array(); + var $query_parameter_values = array(); // }}} // {{{ constructor @@ -794,6 +792,11 @@ $colon = ':'; $positions = array(); $position = 0; + $ignores = array( + $this->string_quoting, + $this->identifier_quoting, + array('start' => '/*', 'end' => '*/', 'escape' => false), + ); while ($position < strlen($query)) { $q_position = strpos($query, $question, $position); $c_position = strpos($query, $colon, $position); @@ -809,30 +812,22 @@ if (is_null($placeholder_type)) { $placeholder_type_guess = $query[$p_position]; } - if (is_int($quote = strpos($query, "'", $position)) && $quote < $p_position) { - if (!is_int($end_quote = strpos($query, "'", $quote + 1))) { - $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'query with an unterminated text string specified', __FUNCTION__); - return $err; - } - switch ($this->escape_quotes) { - case '': - case "'": - $position = $end_quote + 1; - break; - default: - if ($end_quote == $quote + 1) { - $position = $end_quote + 1; - } else { - if ($query[$end_quote-1] == $this->escape_quotes) { - $position = $end_quote; - } else { - $position = $end_quote + 1; + // skip any delimited strings + foreach ($ignores as $ignore) { + if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) { + $end_quote = $start_quote; + do { + if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) { + $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, + 'query with an unterminated text string specified', __FUNCTION__); + return $err; } - } - break; + } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']); + $position = $end_quote + 1; + continue(2); } - } elseif ($query[$position] == $placeholder_type_guess) { + } + if ($query[$position] == $placeholder_type_guess) { if (is_null($placeholder_type)) { $placeholder_type = $query[$p_position]; $question = $colon = $placeholder_type; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mssql.php?r1=1.145&r2=1.146&diff_format=u Index: pear/MDB2/MDB2/Driver/mssql.php diff -u pear/MDB2/MDB2/Driver/mssql.php:1.145 pear/MDB2/MDB2/Driver/mssql.php:1.146 --- pear/MDB2/MDB2/Driver/mssql.php:1.145 Tue Sep 26 15:46:15 2006 +++ pear/MDB2/MDB2/Driver/mssql.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Frank M. Kromann <frank@kromann.info> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.145 2006/09/26 15:46:15 lsmith Exp $ +// $Id: mssql.php,v 1.146 2006/10/14 13:42:02 lsmith Exp $ // // {{{ Class MDB2_Driver_mssql /** @@ -56,10 +56,9 @@ class MDB2_Driver_mssql extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "'"; - - var $escape_identifier = ''; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => false); + var $identifier_quoting = array('start' => '[', 'end' => ']', 'escape' => ']'); // }}} // {{{ constructor @@ -169,29 +168,6 @@ } // }}} - // {{{ quoteIdentifier() - - /** - * Quote a string so it can be safely used as a table / column name - * - * Quoting style depends on which database driver is being used. - * - * @param string $str identifier name to be quoted - * @param bool $check_option check the 'quote_identifier' option - * - * @return string quoted identifier string - * - * @access public - */ - function quoteIdentifier($str, $check_option = false) - { - if ($check_option && !$this->options['quote_identifier']) { - return $str; - } - return '[' . str_replace(']', ']]', $str) . ']'; - } - - // }}} // {{{ beginTransaction() /** http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mysql.php?r1=1.161&r2=1.162&diff_format=u Index: pear/MDB2/MDB2/Driver/mysql.php diff -u pear/MDB2/MDB2/Driver/mysql.php:1.161 pear/MDB2/MDB2/Driver/mysql.php:1.162 --- pear/MDB2/MDB2/Driver/mysql.php:1.161 Sat Oct 14 10:24:51 2006 +++ pear/MDB2/MDB2/Driver/mysql.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.161 2006/10/14 10:24:51 quipo Exp $ +// $Id: mysql.php,v 1.162 2006/10/14 13:42:02 lsmith Exp $ // /** @@ -56,16 +56,13 @@ class MDB2_Driver_mysql extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "\\"; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => '\\', 'escape_pattern' => '\\'); - var $escape_pattern = "\\"; - - var $escape_identifier = '`'; + var $identifier_quoting = array('start' => '`', 'end' => '`', 'escape' => '`'); var $start_transaction = false; var $varchar_max_length = 255; - // }}} // {{{ constructor @@ -782,6 +779,11 @@ $colon = ':'; $positions = array(); $position = 0; + $ignores = array( + $this->string_quoting, + $this->identifier_quoting, + array('start' => '/*', 'end' => '*/', 'escape' => false), + ); while ($position < strlen($query)) { $q_position = strpos($query, $question, $position); $c_position = strpos($query, $colon, $position); @@ -797,30 +799,22 @@ if (is_null($placeholder_type)) { $placeholder_type_guess = $query[$p_position]; } - if (is_int($quote = strpos($query, "'", $position)) && $quote < $p_position) { - if (!is_int($end_quote = strpos($query, "'", $quote + 1))) { - $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'query with an unterminated text string specified', __FUNCTION__); - return $err; - } - switch ($this->escape_quotes) { - case '': - case "'": - $position = $end_quote + 1; - break; - default: - if ($end_quote == $quote + 1) { - $position = $end_quote + 1; - } else { - if ($query[$end_quote-1] == $this->escape_quotes) { - $position = $end_quote; - } else { - $position = $end_quote + 1; + // skip any delimited strings + foreach ($ignores as $ignore) { + if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) { + $end_quote = $start_quote; + do { + if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) { + $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, + 'query with an unterminated text string specified', __FUNCTION__); + return $err; } - } - break; + } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']); + $position = $end_quote + 1; + continue(2); } - } elseif ($query[$position] == $placeholder_type_guess) { + } + if ($query[$position] == $placeholder_type_guess) { if (is_null($placeholder_type)) { $placeholder_type = $query[$p_position]; $question = $colon = $placeholder_type; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mysqli.php?r1=1.139&r2=1.140&diff_format=u Index: pear/MDB2/MDB2/Driver/mysqli.php diff -u pear/MDB2/MDB2/Driver/mysqli.php:1.139 pear/MDB2/MDB2/Driver/mysqli.php:1.140 --- pear/MDB2/MDB2/Driver/mysqli.php:1.139 Sat Oct 14 10:24:51 2006 +++ pear/MDB2/MDB2/Driver/mysqli.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.139 2006/10/14 10:24:51 quipo Exp $ +// $Id: mysqli.php,v 1.140 2006/10/14 13:42:02 lsmith Exp $ // /** @@ -56,16 +56,13 @@ class MDB2_Driver_mysqli extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "\\"; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => '\\', 'escape_pattern' => '\\'); - var $escape_pattern = "\\"; - - var $escape_identifier = '`'; + var $identifier_quoting = array('start' => '`', 'end' => '`', 'escape' => '`'); var $start_transaction = false; var $varchar_max_length = 255; - // }}} // {{{ constructor @@ -804,6 +801,11 @@ $colon = ':'; $positions = array(); $position = 0; + $ignores = array( + $this->string_quoting, + $this->identifier_quoting, + array('start' => '/*', 'end' => '*/', 'escape' => false), + ); while ($position < strlen($query)) { $q_position = strpos($query, $question, $position); $c_position = strpos($query, $colon, $position); @@ -819,30 +821,22 @@ if (is_null($placeholder_type)) { $placeholder_type_guess = $query[$p_position]; } - if (is_int($quote = strpos($query, "'", $position)) && $quote < $p_position) { - if (!is_int($end_quote = strpos($query, "'", $quote + 1))) { - $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'query with an unterminated text string specified', __FUNCTION__); - return $err; - } - switch ($this->escape_quotes) { - case '': - case "'": - $position = $end_quote + 1; - break; - default: - if ($end_quote == $quote + 1) { - $position = $end_quote + 1; - } else { - if ($query[$end_quote-1] == $this->escape_quotes) { - $position = $end_quote; - } else { - $position = $end_quote + 1; + // skip any delimited strings + foreach ($ignores as $ignore) { + if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) { + $end_quote = $start_quote; + do { + if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) { + $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, + 'query with an unterminated text string specified', __FUNCTION__); + return $err; } - } - break; + } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']); + $position = $end_quote + 1; + continue(2); } - } elseif ($query[$position] == $placeholder_type_guess) { + } + if ($query[$position] == $placeholder_type_guess) { if (is_null($placeholder_type)) { $placeholder_type = $query[$p_position]; $question = $colon = $placeholder_type; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/oci8.php?r1=1.179&r2=1.180&diff_format=u Index: pear/MDB2/MDB2/Driver/oci8.php diff -u pear/MDB2/MDB2/Driver/oci8.php:1.179 pear/MDB2/MDB2/Driver/oci8.php:1.180 --- pear/MDB2/MDB2/Driver/oci8.php:1.179 Tue Sep 26 19:23:02 2006 +++ pear/MDB2/MDB2/Driver/oci8.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.179 2006/09/26 19:23:02 justinpatrin Exp $ +// $Id: oci8.php,v 1.180 2006/10/14 13:42:02 lsmith Exp $ /** * MDB2 OCI8 driver @@ -55,14 +55,11 @@ class MDB2_Driver_oci8 extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "'"; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => '@'); - var $escape_pattern = '@'; - - var $escape_identifier = '"'; + var $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"'); var $uncommitedqueries = 0; - // }}} // {{{ constructor @@ -769,6 +766,11 @@ $positions = array(); $position = 0; $parameter = -1; + $ignores = array( + $this->string_quoting, + $this->identifier_quoting, + array('start' => '/*', 'end' => '*/', 'escape' => false), + ); while ($position < strlen($query)) { $q_position = strpos($query, $question, $position); $c_position = strpos($query, $colon, $position); @@ -784,30 +786,22 @@ if (is_null($placeholder_type)) { $placeholder_type_guess = $query[$p_position]; } - if (is_int($quote = strpos($query, "'", $position)) && $quote < $p_position) { - if (!is_int($end_quote = strpos($query, "'", $quote + 1))) { - $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'query with an unterminated text string specified', __FUNCTION__); - return $err; - } - switch ($this->escape_quotes) { - case '': - case "'": - $position = $end_quote + 1; - break; - default: - if ($end_quote == $quote + 1) { - $position = $end_quote + 1; - } else { - if ($query[$end_quote-1] == $this->escape_quotes) { - $position = $end_quote; - } else { - $position = $end_quote + 1; + // skip any delimited strings + foreach ($ignores as $ignore) { + if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) { + $end_quote = $start_quote; + do { + if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) { + $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, + 'query with an unterminated text string specified', __FUNCTION__); + return $err; } - } - break; + } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']); + $position = $end_quote + 1; + continue(2); } - } elseif ($query[$position] == $placeholder_type_guess) { + } + if ($query[$position] == $placeholder_type_guess) { if (is_null($placeholder_type)) { $placeholder_type = $query[$p_position]; $question = $colon = $placeholder_type; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/pgsql.php?r1=1.157&r2=1.158&diff_format=u Index: pear/MDB2/MDB2/Driver/pgsql.php diff -u pear/MDB2/MDB2/Driver/pgsql.php:1.157 pear/MDB2/MDB2/Driver/pgsql.php:1.158 --- pear/MDB2/MDB2/Driver/pgsql.php:1.157 Tue Sep 26 15:46:16 2006 +++ pear/MDB2/MDB2/Driver/pgsql.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.157 2006/09/26 15:46:16 lsmith Exp $ +// $Id: pgsql.php,v 1.158 2006/10/14 13:42:02 lsmith Exp $ /** * MDB2 PostGreSQL driver @@ -55,12 +55,9 @@ class MDB2_Driver_pgsql extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "'"; - - var $escape_pattern = "\\"; - - var $escape_identifier = '"'; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => '\\'); + var $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"'); // }}} // {{{ constructor @@ -788,6 +785,11 @@ $colon = ':'; $positions = array(); $position = $parameter = 0; + $ignores = array( + $this->string_quoting, + $this->identifier_quoting, + array('start' => '/*', 'end' => '*/', 'escape' => false), + ); while ($position < strlen($query)) { $q_position = strpos($query, $question, $position); $c_position = strpos($query, $colon, $position); @@ -803,30 +805,22 @@ if (is_null($placeholder_type)) { $placeholder_type_guess = $query[$p_position]; } - if (is_int($quote = strpos($query, "'", $position)) && $quote < $p_position) { - if (!is_int($end_quote = strpos($query, "'", $quote + 1))) { - $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'query with an unterminated text string specified', __FUNCTION__); - return $err; - } - switch ($this->escape_quotes) { - case '': - case "'": - $position = $end_quote + 1; - break; - default: - if ($end_quote == $quote + 1) { - $position = $end_quote + 1; - } else { - if ($query[$end_quote-1] == $this->escape_quotes) { - $position = $end_quote; - } else { - $position = $end_quote + 1; + // skip any delimited strings + foreach ($ignores as $ignore) { + if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) { + $end_quote = $start_quote; + do { + if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) { + $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, + 'query with an unterminated text string specified', __FUNCTION__); + return $err; } - } - break; + } while ($ignore['escape'] && $query[($end_quote - 1)] == $ignore['escape']); + $position = $end_quote + 1; + continue(2); } - } elseif ($query[$position] == $placeholder_type_guess) { + } + if ($query[$position] == $placeholder_type_guess) { if (is_null($placeholder_type)) { $placeholder_type = $query[$p_position]; $question = $colon = $placeholder_type; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/querysim.php?r1=1.75&r2=1.76&diff_format=u Index: pear/MDB2/MDB2/Driver/querysim.php diff -u pear/MDB2/MDB2/Driver/querysim.php:1.75 pear/MDB2/MDB2/Driver/querysim.php:1.76 --- pear/MDB2/MDB2/Driver/querysim.php:1.75 Sun Aug 20 09:48:43 2006 +++ pear/MDB2/MDB2/Driver/querysim.php Sat Oct 14 13:42:02 2006 @@ -61,7 +61,7 @@ // | please contact Alan Richmond. | // +----------------------------------------------------------------------+ // -// $Id: querysim.php,v 1.75 2006/08/20 09:48:43 lsmith Exp $ +// $Id: querysim.php,v 1.76 2006/10/14 13:42:02 lsmith Exp $ // /* @@ -215,10 +215,6 @@ */ class MDB2_Driver_querysim extends MDB2_Driver_Common { - var $escape_quotes = "\\"; - - var $escape_identifier = ''; - // }}} // {{{ constructor @@ -233,22 +229,22 @@ $this->dbsyntax = 'querysim'; // Most of these are dummies to simulate availability if checked - $this->supported['sequences'] = 'emulated'; - $this->supported['indexes'] = true; + $this->supported['sequences'] = false; + $this->supported['indexes'] = false; $this->supported['affected_rows'] = false; $this->supported['summary_functions'] = false; $this->supported['order_by_text'] = false; - $this->supported['current_id'] = 'emulated'; + $this->supported['current_id'] = false; $this->supported['limit_queries'] = true;// this one is real $this->supported['LOBs'] = true; - $this->supported['replace'] = 'emulated'; - $this->supported['sub_selects'] = 'emulated'; + $this->supported['replace'] = false; + $this->supported['sub_selects'] = false; $this->supported['transactions'] = false; $this->supported['savepoints'] = false; $this->supported['auto_increment'] = false; $this->supported['primary_key'] = false; $this->supported['result_introspection'] = false; // not implemented - $this->supported['prepared_statements'] = 'emulated'; + $this->supported['prepared_statements'] = false; $this->supported['identifier_quoting'] = false; $this->supported['pattern_escaping'] = false; http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/sqlite.php?r1=1.137&r2=1.138&diff_format=u Index: pear/MDB2/MDB2/Driver/sqlite.php diff -u pear/MDB2/MDB2/Driver/sqlite.php:1.137 pear/MDB2/MDB2/Driver/sqlite.php:1.138 --- pear/MDB2/MDB2/Driver/sqlite.php:1.137 Sun Aug 20 09:48:43 2006 +++ pear/MDB2/MDB2/Driver/sqlite.php Sat Oct 14 13:42:02 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.137 2006/08/20 09:48:43 lsmith Exp $ +// $Id: sqlite.php,v 1.138 2006/10/14 13:42:02 lsmith Exp $ // /** @@ -56,9 +56,9 @@ class MDB2_Driver_sqlite extends MDB2_Driver_Common { // {{{ properties - var $escape_quotes = "'"; + var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => false); - var $escape_identifier = '"'; + var $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"'); var $_lasterror = '';
« previous php.pear.cvs (#42550) next »