R: [PHP] Handling Database errors in php
| From: | Alessandro Vitale | Date: | Fri, 05 Dec 2003 13:35:13 +0000 |
| Subject: | R: [PHP] Handling Database errors in php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171982@lists.php.net to get a copy of this message | ||
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:manoj@mail15.com]
Inviato: venerdì 5 dicembre 2003 13.07
A: php-general@lists.php.net
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