I am not sure if this could match you requirements but I often use this
pattern:

"INSERT IGNORE... SET VAR=0"
"UPDATE..."

the first query will do the insert if not present a record with a same
unique index key
the second will be redundand if the first succeed and will do the job if the
first fails

both of the query should be designed for not to raise any error

cheers.

alessandro

-----Messaggio originale-----
Da: manoj nahar [mailto:[EMAIL PROTECTED]
Inviato: venerd́ 5 dicembre 2003 13.07
A: [EMAIL PROTECTED]
Oggetto: [PHP] Handling Database errors in php


Hi guys,

Column of table defined as primary key. there is violation and error
message from database.

1) First way is to check if the value is already in database and then
contuninue with insert
        (this invloes an extra select for every insert and leaves
defined primary key redundant)


What is the best approach to be followed for this scenario.?
what if there are several constrains defined on a table?

cheers

Manoj

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to