Index: oci8.php =================================================================== RCS file: /repository/pear/DB/DB/oci8.php,v retrieving revision 1.17 diff -u -r1.17 oci8.php --- oci8.php 6 Dec 2003 09:04:13 -0000 1.17 +++ oci8.php 10 Dec 2003 18:28:25 -0000 @@ -249,6 +249,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 + * + boolean = 1 if true or + * 0 if false. Use the NUMBER(1) + * data type because Oracle doesn't have BOOLEAN. + * + 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 ? 1 : 0; + } elseif (is_null($str)) { + return 'NULL'; + } else { + return "'" . str_replace("'", "''", $str) . "'"; + } + } + + // }}} // {{{ numRows() function numRows($result)