Thor
Honorary Master
- Joined
- Jun 5, 2014
- Messages
- 44,236
Right this is what I have in the Foreach loop:
This is what it looks like in the DB ( I dropped all the stuff so it was a clean start (empty table) )
I have made the hash a CHAR type with a length of 64
However if I run the SQL query again it adds the duplicates:

PHP:
$unique_hash = hash('SHA256', $title.$link);
$statement = $db->prepare("INSERT INTO market_feed (`title`, `description`, `link`, `date`, `unique_hash` ) SELECT * FROM (SELECT :title, :description, :link, :date, :unique_hash) AS tmp WHERE NOT EXISTS ( SELECT `unique_hash` FROM market_feed WHERE unique_hash= ':unique_hash') LIMIT 1;");
$statement->execute(array(':title' => $title, ':description' => $description, ':link' => $link, ':date' => $date, ':unique_hash' => $unique_hash));
This is what it looks like in the DB ( I dropped all the stuff so it was a clean start (empty table) )
I have made the hash a CHAR type with a length of 64
However if I run the SQL query again it adds the duplicates:
Last edited: