Thomas Svenson wrote:

BAO RuiXian wrote:


Make it field UNIQUE.



That's the easy method, but usually not very smart. It only causes MySQL to


Well, if there is an easy method, why we bother to use a more complicacted way?

generate an error which you then have to take care of in your application.


We need to take care of various errors any way whenever we are dealing with databases.

Much better to have an index on the Username column and then use a select to
check if the name exist. If it doesn't it is OK to insert. Much easier to
handle in PHP.


Quite to the opposite, if the database can handle it, why bother to write one's own with something adding more burden to the database (select statement), more process on the php code (check each item of the select result) and possibly less error-proof in your php checking code?

Personally I avoid using such things as UNIQUE or NOT_NULL (unless the
column have a default value) on columns, just because it is more complex to
handle the MySQL errors than write your own code to check it in PHP.


Can't get it. If there is a existing method, why not use it. The home-brew one is always low in aspects. I don't understand why you think checking errors is complext, which has to be done in all your codes, even a trivial one.

/T


Best

Bao

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



Reply via email to