William Stokes a écrit :
Hello,
I'm updating a table with following SQL statement
$sql = "INSERT INTO x_ikaluokat (ryhma, ikaluokka)
VALUES ('$ryhma','$ikaluokka')";
What would be the best way to test that similar rows doesn't get created to
the table? I can't make both columns unique.
Can't you define a key in your sql table, to avoid "similar raws" ?
otherwise, you can set an array with both values
$my_array[$ryhma] = $ikaluokka;
and test for each insert
if ( !array_key_exists($ryhma,$my_array))
{ $sql = "INSERT ...";
}
elseif ( $my_array[$ryhma] != $ikaluokka )
{ $sql = "INSERT ...";
}
but if you have a lot of insert, the script needs a lot of memory to run
properly.
N F
Thanks
-Will
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php