|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-04-02 11:35 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 08:00:01 2025 UTC |
Description: ------------ I am using mysql 5.0.27. There is a table that has a unique index on it. When inserting a new row that would violate the uniqueness using a prepared statement no errors/exceptions are raised. When looking at the query log the statement is prepared but no executions queries. Should there not be an exception raised for the error? I did a google search and searched the bug database but did not find an existing issue. Reproduce code: --------------- CREATE TABLE `docs_classification` ( `classification_id` smallint(6) NOT NULL auto_increment, `name` varchar(100) NOT NULL, `description` varchar(255) NOT NULL, `short_name` char(3) NOT NULL, `bit_value` int(11) NOT NULL, PRIMARY KEY (`classification_id`), UNIQUE KEY `bit_value` (`bit_value`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; ////////// First Run array('test1', 'test1test1', 'TS1', '1'), array('test2', 'test2test2', 'TS2', '2'), array('test3', 'test3test3', 'TS3', '4') ); $m = new mysqli('localhost', 'dbuser', '','dbname'); $sql = 'INSERT INTO dbtable ' ' (classification_id, name, description, short_name, bit_value) '. ' VALUES (NULL, ?, ?, ?, ?)'; $stmt = $m->prepare($sql); foreach ($a as $b) { $stmt->bind_param('ssss', $b[0], $b[1], $b[2], $b[3]); $stmt->execute(); } /////// Then repeat above code and no errors are raised. Expected result: ---------------- Expected to be notified of the duplicate entry error in the bit_value field when re-running the code. Actual result: -------------- No errors or indication of any errors. In the query log it shows the sql being prepared but no Execute commands.