Re: DB_common escapeSimple() not found
| From: | brian | Date: | Fri, 04 Nov 2005 00:08:41 +0000 |
| Subject: | Re: DB_common escapeSimple() not found | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21768@lists.php.net to get a copy of this message | ||
Justin Patrin wrote:
On 11/3/05, brian <brian@zijn-digital.com> wrote:string(29) "/usr/local/php/lib/php/DB.php" [5]=> string(31) "/usr/local/php/lib/php/PEAR.php" [6]=> string(35) "/usr/local/php/lib/php/DB/pgsql.php" [7]=> string(36) "/usr/local/php/lib/php/DB/common.php" Once again, the method not being found is DIRECTLY BELOW the method calling it in the source. Unless PHP is somehow not including *part* of a file, it's not a file inclusion problem. The error exists whether i use DB_common::quoteSmart() or DB_pgsql::quoteSmart(). My only recourse has been to modify the source to add escapeSimple()'s code inside quoteSmart(). Here is the relevant (unedited) source from db_common.php: --- snip ---Just try what I mentioned. In addition, you might want to check for errors. An error is exactly what i'm enquiring about. As for included files, among others:The error is thrown *inside* common.php while attempting to call the method escapesimple() from quoteSmart(). escapeSimple() is right there in the source below quoteSmart(). The very same problem occurs whether i use common.php or pgsql.php.This is pretty strange. PHP refuses to recognize escapeSimple method called from quoteSmart(). This happens whether i call DB_common::quoteSmart() or DB_pgsql::quoteSmart().Sound slike you may have an upgrade/include_path problem. Use get_included_files() to make sure all of the DB stuff is being included from the same place.
function quoteSmart($in)
{
if (is_int($in) || is_double($in)) {
return $in;
} elseif (is_bool($in)) {
return $in ? 1 : 0;
} elseif (is_null($in)) {
return 'NULL';
} else {
return "'" . $this->escapeSimple($in) . "'";
}
}
// }}}
// {{{ escapeSimple()
/**
* Escapes a string according to the current DBMS's standards
*
* In SQLite, this makes things safe for inserts/updates, but may
* cause problems when performing text comparisons against columns
* containing binary data. See the
* {@link http://php.net/sqlite_escape_string PHP manual} for more info.
*
* @param string $str the string to be escaped
*
* @return string the escaped string
*
* @see DB_common::quoteSmart()
* @since Method available since Release 1.6.0
*/
function escapeSimple($str)
{
return str_replace("'", "''", $str);
}
--- snip ---
The error msg is "Fatal error: Call to undefined function:
escapesimple() in /usr/local/php/lib/php/DB/common.php on line 434"
Steps to reproduce:
script has these includes:
require_once "${_SERVER['DOCUMENT_ROOT']}/includes/php/get_dbi.php";
require_once "${_SERVER['DOCUMENT_ROOT']}/includes/php/MyClass.php";
get_dbi.php gets a DB connection and has:
require('DB.php');
inside MyClass:
DB_common::quoteSmart($some_string);
I get the same error if i add require_once('DB.php') to MyClass.
Can anyone verify this or suggest why this could be happening?
brian