Re: Re: customer ids
| From: | Burn | Date: | Wed, 06 Jun 2007 16:23:03 +0000 |
| Subject: | Re: Re: customer ids | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256199@lists.php.net to get a copy of this message | ||
Richard Davey ha scritto:
Hi Burn, Wednesday, June 6, 2007, 4:39:05 PM, you wrote:True, true :)Worst thing that can happen is having mysql throw an error while trying to insert an ID that's already present in the database. It gets more complicated and unpredictable if the field isn't required to be unique at database design level.Wanting to make it perfectly safe the check should include the INSERT statement and continue looping till it's successful as well.Or just wrap the whole thing in a stored procedure / transaction (it's what they were invented for after-all :), tasks like this should be pushed to SQL as much as possible imho. Cheers, Rich