RE: [PHP] verifying sql INSERTs
| From: | Chris W. Parker | Date: | Tue, 26 Aug 2003 16:34:42 +0000 |
| Subject: | RE: [PHP] verifying sql INSERTs | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-160801@lists.php.net to get a copy of this message | ||
Marek Kilimajer <mailto:kilimajer@webglobe.sk>
on Tuesday, August 26, 2003 3:59 AM said:
> mysql_query() will return true for queries that don't return rows and
> were executed without error, so you can use
> return mysql_query();
> You should also make a UNIQUE index on email column, then you can
> check the number returned by mysql_errno(), one number I don't
> remember signals duplicate entry error.
OOhhh... You know, I already HAVE done this, and I just came to the
realization that if I've already got a constraint on the email column
then why the heck am I checking to see if the value is already there?
That's just a waste of resources.
I should instead just try to perform the INSERT and then if it fails I
know I've already got a record. If it doesn't I know everything is cool.
Good idea!
Chris.