Index: sybase.php
===================================================================
RCS file: /repository/pear/DB/DB/sybase.php,v
retrieving revision 1.15
diff -u -r1.15 sybase.php
--- sybase.php 18 Sep 2003 19:29:46 -0000 1.15
+++ sybase.php 16 Dec 2003 04:26:18 -0000
@@ -325,6 +325,38 @@
}
// }}}
+ // {{{ 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
+ * + integer or double = the unquoted number
+ * + boolean = 1 if true or
+ * 0 if false. Use the TINYINT(1) data type.
+ * Sybase doesn't have BOOLEAN and BIT can't be null.
+ * + 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 ? 1 : 0;
+ } elseif (is_null($str)) {
+ return 'NULL';
+ } else {
+ return "'" . str_replace("'", "''", $str) . "'";
+ }
+ }
+
+ // }}}
// {{{ numCols()
/**