php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23344 wrong variable in DB common
Submitted: 2003-04-25 08:33 UTC Modified: 2003-05-21 20:12 UTC
From: tomas at dupoint dot com Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.3.0 OS: win2000
Private report: No CVE-ID: None
 [2003-04-25 08:33 UTC] tomas at dupoint dot com
OK... 

A WHERE-statement is sent to this method. Look how it's set in $where but when it's used the variable $sql is used instead!! The query becomes "UPDATE $table SET $set WHERE UPDATE $table SET $set"

The error is marked with >>>>


    function buildManipSQL($table, $table_fields, $mode, $where = false)
    {
        if (count($table_fields)==0) {
            $this->raiseError(DB_ERROR_NEED_MORE_DATA);
        }
        $first = true;
        switch($mode) {
        case DB_AUTOQUERY_INSERT:
            $values = '';
            $names = '';
            while (list(, $value) = each($table_fields)) {
                if ($first) {
                    $first = false;
                } else {
                    $names .= ',';
                    $values .= ',';
                }
                $names .= $value;
                $values .= '?';
            }
            return "INSERT INTO $table ($names) VALUES ($values)";
            break;
        case DB_AUTOQUERY_UPDATE:
            $set = '';
            while (list(, $value) = each($table_fields)) {
                if ($first) {
                    $first = false;
                } else {
                    $set .= ',';
                }
                $set .= "$value = ?";
            }
            $sql = "UPDATE $table SET $set";
            if ($where) {
>>>>           $sql .= " WHERE $sql";
            }
            return $sql;
            break;
        default:
            $this->raiseError(DB_ERROR_SYNTAX);
        }
    }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-26 17:59 UTC] philip@php.net
This was fixed on Mon Jul 29 07:21:30 2002, although, thanks for the report :)

http://cvs.php.net/diff.php/pear/DB/DB/common.php?r1=1.9&r2=1.10
 [2003-05-21 20:12 UTC] sniper@php.net
fixed -> closed..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 08:01:30 2024 UTC