cvs: php4 /pear/DB pgsql.php

From: Date: Sat, 14 Jul 2001 19:56:17 +0000
Subject: cvs: php4 /pear/DB pgsql.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-274@lists.php.net to get a copy of this message
cox Sat Jul 14 15:56:17 2001 EDT Modified files: /php4/pear/DB pgsql.php Log: added a native quote method Index: php4/pear/DB/pgsql.php diff -u php4/pear/DB/pgsql.php:1.39 php4/pear/DB/pgsql.php:1.40 --- php4/pear/DB/pgsql.php:1.39 Sun Jul 8 20:16:34 2001 +++ php4/pear/DB/pgsql.php Sat Jul 14 15:56:17 2001 @@ -313,6 +313,30 @@ } // }}} + // {{{ quote() + /** + * Quote the given string so it can be safely used within string delimiters + * in a query. + * @param $string mixed Data to be quoted + * @return mixed "NULL" string, quoted string or original data + */ + function quote($str = null) + { + switch (strtolower(gettype($str))) { + case 'null': + return 'NULL'; + case 'integer': + case 'double' : + return $str; + case 'string': + default: + $str = str_replace("'", "''", $str); + //PostgreSQL treats a backslash as an escape character. + $str = str_replace('\\', '\\\\', $str); + return "'$str'"; + } + } + // }}} // {{{ numCols() /**

« previous php.pear.cvs (#274) next »