cvs: pear /DB/DB common.php oci8.php
| From: | Daniel Convissor | Date: | Sat, 03 Jan 2004 20:48:38 +0000 |
| Subject: | cvs: pear /DB/DB common.php oci8.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-15315@lists.php.net to get a copy of this message | ||
danielc Sat Jan 3 15:48:38 2004 EDT
Modified files:
/pear/DB/DB common.php oci8.php
Log:
Allow ! as placeholder in prepare(). Bug 91.
Index: pear/DB/DB/common.php
diff -u pear/DB/DB/common.php:1.35 pear/DB/DB/common.php:1.36
--- pear/DB/DB/common.php:1.35 Sat Jan 3 02:01:46 2004
+++ pear/DB/DB/common.php Sat Jan 3 15:48:37 2004
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: common.php,v 1.35 2004/01/03 07:01:46 danielc Exp $
+// $Id: common.php,v 1.36 2004/01/03 20:48:37 danielc Exp $
//
// Base class for DB implementations.
//
@@ -29,7 +29,7 @@
* inherited by all such.
*
* @package DB
- * @version $Id: common.php,v 1.35 2004/01/03 07:01:46 danielc Exp $
+ * @version $Id: common.php,v 1.36 2004/01/03 20:48:37 danielc Exp $
* @category Database
* @author Stig Bakken <ssb@php.net>
* @author Tomas V.V.Cox <cox@idecnet.com>
@@ -408,6 +408,11 @@
* in a db)
* ! - value is inserted 'as is'
*
+ * Use backslashes to escape wildcard characters if you don't want
+ * them to be interpreted as wildcards. Example: <samp>
+ * "UPDATE foo SET col=? WHERE col='over \& under'"
+ * </samp>
+ *
* @param string the query to prepare
*
* @return resource handle for the query
@@ -418,7 +423,7 @@
function prepare($query)
{
- $tokens = split('[&?!]', $query);
+ $tokens = preg_split('/(?<!\\\)[&?!]/', $query);
$token = 0;
$types = array();
$qlen = strlen($query);
@@ -435,6 +440,10 @@
break;
}
}
+
+ foreach ($tokens as $key => $val) {
+ $tokens[$key] = preg_replace('/\\\([&?!])/', "\\1", $val);
+ }
$this->prepare_tokens[] = &$tokens;
end($this->prepare_tokens);
Index: pear/DB/DB/oci8.php
diff -u pear/DB/DB/oci8.php:1.21 pear/DB/DB/oci8.php:1.22
--- pear/DB/DB/oci8.php:1.21 Sat Jan 3 02:01:46 2004
+++ pear/DB/DB/oci8.php Sat Jan 3 15:48:37 2004
@@ -16,7 +16,7 @@
// | Author: James L. Pine <jlp@valinux.com> |
// +----------------------------------------------------------------------+
//
-// $Id: oci8.php,v 1.21 2004/01/03 07:01:46 danielc Exp $
+// $Id: oci8.php,v 1.22 2004/01/03 20:48:37 danielc Exp $
//
// Database independent query interface definition for PHP's Oracle 8
// call-interface extension.
@@ -376,7 +376,7 @@
*/
function prepare($query)
{
- $tokens = split('[\&\?]', $query);
+ $tokens = split('[&?!]', $query);
$token = 0;
$types = array();
$qlen = strlen($query);
@@ -388,6 +388,9 @@
case '&':
$types[$token++] = DB_PARAM_OPAQUE;
break;
+ case '!':
+ $types[$token++] = DB_PARAM_MISC;
+ break;
}
}
$binds = sizeof($tokens) - 1;