Ben iki tablo ile bir veritabanı 'test' var.
İşte phpmyadmin dökümü:
CREATE TABLE IF NOT EXISTS `tags` (
`name` varchar(100) NOT NULL,
`id` int(4) NOT NULL,
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tags`
--
INSERT INTO `tags` (`name`, `id`) VALUES
('tag_one', 1),
('tag_two', 1),
('tag_three', 1);
-- --------------------------------------------------------
--
-- Table structure for table `tags_used`
--
CREATE TABLE IF NOT EXISTS `tags_used` (
`name` varchar(100) NOT NULL,
`used` int(4) NOT NULL,
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tags_used`
--
INSERT INTO `tags_used` (`name`, `used`) VALUES
('tag_one', 10),
('tag_three', 10),
('tag_two', 10);
Ve burada php kodu:
<?php
$mysqli = new mysqli('127.0.0.1', 'root', 'pass', 'test');
if ($mysqli->connect_error) {
echo 'Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error;
}
else {
$query = <<<SQL
DELETE FROM `tags` WHERE `tags`.`name` = 'tag_one' AND `tags`.`id` = '1';
UPDATE `tags_used` SET `used` = used-1 WHERE `tags_used`.`name` = 'tag_one';
DELETE FROM `tags` WHERE `tags`.`name` = 'tag_two' AND `tags`.`id` = '1';
UPDATE `tags_used` SET `used` = used-1 WHERE `tags_used`.`name` = 'tag_two';
DELETE FROM `tags` WHERE `tags`.`name` = 'tag_three' AND `tags`.`id` = '1';
UPDATE `tags_used` SET `used` = used-1 WHERE `tags_used`.`name` = 'tag_three';
SQL;
$query = trim($query);
$mysqli->multi_query($query);
$mysqli->close();
}
?>
After execution 'tag_three' is still in the tags
table.
And when I run this SQL through phpmyadmin it works fine.
Where am I wrong?
mysql 5.1.42
php 5.3.1
windows 2003
nginx 0.8.32
MySQL.log
C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld, Version: 5.1.42-community-log (MySQL Community Server (GPL)). started with:
TCP Port: 3306, Named Pipe: (null)
Time Id Command Argument
100821 12:25:52 1 Connect root@localhost on test
1 Query DELETE FROM `tags` WHERE `tags`.`name` = 'tag_one' AND `tags`.`id` = '1';
UPDATE `tags_used` SET `used` = used-1 WHERE `tags_used`.`name` = 'tag_one';
DELETE FROM `tags` WHERE `tags`.`name` = 'tag_two' AND `tags`.`id` = '1';
UPDATE `tags_used` SET `used` = used-1 WHERE `tags_used`.`name` = 'tag_two';
DELETE FROM `tags` WHERE `tags`.`name` = 'tag_three' AND `tags`.`id` = '1';
UPDATE `tags_used` SET `used` = used-1 WHERE `tags_used`.`name` = 'tag_three'
100821 12:27:37 2 Connect root@localhost on
2 Query SET CHARACTER SET 'utf8'
2 Query SET collation_connection = 'utf8_general_ci'
2 Query SHOW PLUGINS
2 Init DB test
2 Init DB test
2 Query SELECT * FROM `tags`
LIMIT 0, 30
2 Query SHOW TABLE STATUS FROM `test` LIKE 'tags%'
2 Query SELECT COUNT(*) FROM `test`.`tags`
2 Init DB test
2 Init DB test
2 Query SHOW VARIABLES LIKE 'profiling'
2 Query SHOW FULL COLUMNS
FROM `test`.`tags`
2 Quit
1 Connect - It is my code
2 Connect - It is 'Refresh' from phpmyadmin
Php günlüklerinde hiçbir hata yoktur.
Bu kod boyunca durmak. Gibi. Bu kod önce veya sonra herhangi bir soru yoktur.