I am trying to insert some blind values that is exported from csv to database. During the process it is inserting anything I give without even showing me any warnings.
example: I have a table structure as below
# column-name type
-- --- ----
1 id int(11)
2 name varchar(32)
3 bool tinyint(1)
insert query:
INSERT INTO `table_name` (`id`, `name`, `bool`) VALUES ('a', '11111', 'abced');
When I try to run the above query it does inserts a row but pops out a warning.. I found a solution that I understand it is not the right way.
my try
INSERT INTO `table_name` (`id`, `name`, `bool`) VALUES ('a', '11111', 'abced');
php
$warningCount = count fetched after executing the query "SELECT @@warning_count"
if($WarningCount > 0){ DELETE THE ROW INSERTED and ECHO error Message}
Try setting SQL mode to STRICT_ALL_TABLES.
MySQL documentation states:
Then insert in transaction. Failed insert queries will no be counted. Keep in mind that MySQL transactions are not fully atomic in the sense of the “all or nothing” rule. You can commit a transaction with half of the statements done, and the other half failed.