From:             [EMAIL PROTECTED]
Operating system: 
PHP version:      4.0.6
PHP Bug Type:     Unknown/Other Function
Bug description:  PEAR/DB :  DB_common::executeEmulateQuery()  bug

Multiple execution emulation fails as in the following script: 
<?php
  $db  = DB::connect("mysql://localhost/test");
  $some_query_with_params = "DELETE FROM TST WHERE id = ? ";
  $params = array(1,2,3);
  $stmt = $db->prepare($some_query_with_params); 
  foreach($params as $param)
    $db->execute($stmt, array($param)); //Fails !!!
?>

The reason for that is executeEmulateQuery() code:

    function executeEmulateQuery($stmt, $data = false)
    {
        $p = &$this->prepare_tokens;
        $stmt = (int)$this->prepare_maxstmt++; // BUG ?

        if (!isset($this->prepare_tokens[$stmt]) ||
            !is_array($this->prepare_tokens[$stmt]) ||
            !sizeof($this->prepare_tokens[$stmt])) {
            return $this->raiseError(DB_ERROR_INVALID);
        }

        $qq = &$this->prepare_tokens[$stmt];
        // and so on...
What does the second line do?:
  $stmt = (int)$this->prepare_maxstmt++;
It ignores the input parameter $stmt, sets it to some unreasonable value,
and we always get DB_ERROR_INVALID. If the line is removed - everything
works. Apparently this line should not be here at all.


-- 
Edit bug report at: http://bugs.php.net/?id=12137&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to