Ryan A wrote:
want i want to do is, do a select and get the data that is already in the db, compare it, and if its in the insert statement delete those rows... am getting screwed up in the logic for this...so far I have exploaded the insert statement so its in a neat array, now i need to check in_array...
If it was me I'd just use MySQL's INSERT IGNORE [1] which treats errors as warnings instead. So that way when you have a duplicate on your primary key, as you will when inserting a row that already exists, it will ignore the error and carry on. Of course, you'll want to make sure there's no SQL errors etc. before putting the IGNORE keyword in.
Note that you should only really use this in situations where you *know* that a primary or unique key may be duplicated in your INSERT. Sticking IGNORE in all your INSERTs is a Bad Thing since you usually want to know when an error has occurred.
[1] http://dev.mysql.com/doc/mysql/en/insert.html -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php