+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| Destina | Sender | StartTime | EndTime | Created |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| 0877222 | 2100 | 10132014010456 | 10132014010459 | 2014-10-13 10:35:46 |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| 0877222 | 2100 | 10132014010456 | 10132014010459 | 2014-10-13 10:35:46 |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| 0888333 | 4100 | 10132014010433 | 10132014010443 | 2014-10-13 10:35:46 |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| 0888333 | 4100 | 10132014010433 | 10132014010443 | 2014-10-13 10:35:46 |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| 0566666 | 3400 | 10132014010432 | 10132014010452 | 2014-10-13 10:35:46 |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| 0566666 | 3400 | 10132014010432 | 10132014010452 | 2014-10-13 10:35:46 |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
I insert above table from data I retrieved from some API, to prevent duplication in "Destina", "Sender", "StartTime", "EndTime" columns I use MySQL INSERT IGNORE query
here is my code:
$data = array(
'Destina' => $json['Destina'],
'Sender' => $json['Sender'],
'StartTime' => $json['StartTime'],
'EndTime' => $json['EndTime'],
'created' => date('Y-m-d H:i:s')
);
$redis_data = sprintf(
'INSERT IGNORE INTO my_table (%s) VALUES ("%s")',
implode(',',array_keys($data)),
implode('","',array_values($data))
);
$result = mysql_query($redis_data);
But duplication still happen, how do I get this over, I have try to add primary key to above columns but I got this message:
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
Thank you