Index: ibase.php
===================================================================
RCS file: /repository/pear/DB/DB/ibase.php,v
retrieving revision 1.17
diff -u -r1.17 ibase.php
--- ibase.php 6 Dec 2003 09:04:13 -0000 1.17
+++ ibase.php 10 Dec 2003 18:28:10 -0000
@@ -261,6 +261,37 @@
}
// }}}
+ // {{{ quote()
+
+ /**
+ * Quote the given string so it can be safely used in a query.
+ *
+ * @param $str mixed data to be quoted
+ *
+ * @return mixed Submitted variable's type = returned value:
+ * + null = the string NULL
+ * + boolean = the string TRUE or
+ * FALSE
+ * + integer or double = the unquoted number
+ * + other (including strings and numeric strings) =
+ * the data with single quotes escaped by preceeding
+ * single quotes then the whole string is encapsulated
+ * between single quotes
+ */
+ function quote($str = null)
+ {
+ if (is_int($str) || is_double($str)) {
+ return $str;
+ } elseif (is_bool($str)) {
+ return $str ? 'TRUE' : 'FALSE';
+ } elseif (is_null($str)) {
+ return 'NULL';
+ } else {
+ return "'" . str_replace("'", "''", $str) . "'";
+ }
+ }
+
+ // }}}
// {{{ numCols()
function numCols($result)