Re[2]: [PHP] Re: customer ids
| From: | Richard Davey | Date: | Wed, 06 Jun 2007 15:45:23 +0000 |
| Subject: | Re[2]: [PHP] Re: customer ids | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256191@lists.php.net to get a copy of this message | ||
Hi Burn,
Wednesday, June 6, 2007, 4:39:05 PM, you wrote:
> 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
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"