Home » Database » DB » Bug #3841
Statement Prepare function too greedy
Details
| Submitted | 2005-03-16 10:23 UTC |
|---|---|
| From | sintemaa at hotmail dot com |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-03-16 10:23 UTC] sintemaa at hotmail dot com
Description:
------------
The Statement preparation function in DB tries to find all wildcards so they can be replaced during execution.
For this is recognizes all instances of ?, ! and & as wildcards.
However in MySQL != is used as unequal operator. Prepare recognizes the ! as a wildcard, takes it out, and on execution it crieds a mismatch as you don't supply enough parameters for the foudn wildcards.
Reproduce code:
---------------
$sql = 'SELECT * FROM mytable WHERE id < ? AND id != 10';
$sth = $db->prepare($sql);
$result = $db->execute($sth, 100);
Expected result:
----------------
$result should contain all rows from mytable where the id is smaller than 100 and not equal to 10
Actual result:
--------------
A DB_Error is returned
Standard Message: DB Error: mismatch
Standard Code: -7
DBMS/User Message: SELECT * FROM mytable WHERE id < AND id = 10 [DB Error: mismatch]