0
根據我在這裏和網上閱讀的內容,如果您嘗試存儲>INT's maximum signed value; 2147483647的整數,則會出現此錯誤。如下所示,我使用bigint(20)
作爲user_id
。所以,我不知道爲什麼我得到這個錯誤。重複鍵'2147483647''PRIMARY'
CREATE TABLE IF NOT EXISTS `users` (
`user_id` bigint(20) unsigned NOT NULL,
`screen_name` varchar(20) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`profile_image_url` varchar(200) DEFAULT NULL,
`created_at` datetime NOT NULL,
`followers_count` int(10) unsigned DEFAULT NULL,
`friends_count` int(10) unsigned DEFAULT NULL,
`statuses_count` int(10) unsigned DEFAULT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`),
KEY `user_name` (`name`),
KEY `last_update` (`last_update`),
KEY `screen_name` (`screen_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
PHP腳本來處理插入:
/* Prepare an insert statement */
$query = "INSERT INTO users (user_id, screen_name, name, profile_image_url, created_at, followers_count, friends_count, statuses_count) VALUES (?,?,?,?,?,?,?,?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("issssiii", $user_id, $screen_name, $name, $profile_image_url, $created_at, $followers_count, $friends_count, $statuses_count);
/* Execute the statement */
$stmt->execute()
FYI:這個腳本&表是存放一些Twitter的用戶數據的目的
只是爲了仔細檢查,做'DESCRIBE users'顯示user_id作爲bigint嗎? – Mike 2014-10-03 20:20:50
還要確保該值絕對不存在。嘗試插入一個稍大的值。 – 2014-10-03 20:22:05
@Mike是的。確切地說'bigint(20)unsigned'。 – iTurki 2014-10-03 20:22:08