php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25439 $dbh->quoteString returns NULL
Submitted: 2003-09-08 16:49 UTC Modified: 2004-01-22 14:13 UTC
From: jeremy at deadbeef dot com Assigned: danielc (profile)
Status: Not a bug Package: PEAR related
PHP Version: 4.3.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 - 5 = ?
Subscribe to this entry?

 
 [2003-09-08 16:49 UTC] jeremy at deadbeef dot com
Description:
------------
In the PEAR DB module, the quoteString function returns the string "NULL" when passed a null.  This makes a literal "NULL" get written into the database which is a problem.  For better backwards compatibility with the pre-quote() API please consider this implementation for pear/DB/common.php:


    function quoteString($string)
    {
        $string = $this->quote($string);
        if ($string == "NULL")
            return "";
        if ($string{0} == "'") {
            return substr($string, 1, -1);
        }
        return $string;
    }


Reproduce code:
---------------
$val=$dbh->getOne("select null");
echo "The value is:", $dbh->quote($val);

Expected result:
----------------
The value is:

Actual result:
--------------
The value is:NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-22 14:13 UTC] danielc@php.net
quoteString() has been depricated since release 1.2 or even earlier.

CVS commits made earlier today introduced new quoting methods: quoteSmart() and escapeSimple() and depricated the quote() method.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC