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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tomas at dupoint dot com
New email:
PHP Version: OS:

 

 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 02:03:36 2021 UTC