So, for sake of simplicity, let's say I've got a table like this (f1,f2,f3 are fields):
f1 f2 f3
a b c
d e f
And say I've got a PHP array like this I want to add in to the table:
a g h
Now, I want to be able to add this one in, but I don't want to be able to add something like this:
a e f
Field f1 can have duplicates. Fields f2 & f3 cannot. I've tried adding a unique index to f2, and used REPLACE INTO
, but it's not what I want. I need there to be a way to only insert if the f2 & f3 field entries are not already found on the same row in the database table.
$query = "REPLACE INTO table1 (title, description, start, end, location, affiliation)
VALUES ('{$my_title_php_array[$count]}',
'{$my_description_php_array[$count]}',
'{$my_start_php_array[$count]}',
'{$my_end_php_array[$count]}',
'{$my_location_php_array[$count]}',
'{$my_affiliation_php_array[$count]}')”;
description
is of data type 'TEXT', which can't be used as an INDEX
(too big). Ideally, I'd like to have all be necessarily checked in comparison with the incoming PHP array entries.
Let's say I have these things in my new example's PHP array:
Title1 Desc1 1:00pm 2:00pm Loc1 Aff1
Title1 Desc1 3:00pm 4:00pm Loc1 Aff1
Title2 Desc2 1:00pm 2:00pm Loc2 Aff2
Title2 Desc1 1:00pm 2:00pm Loc3 Aff3
These should all be considered unique and entered in. I'd like to be able to enter them only when they don't exactly match a row in my database already. Desc1 is long. The descriptions are usually the most unique. Is there a way of shortening?