|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-09-06 19:04 UTC] cox@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 00:00:01 2025 UTC |
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.