multiple fields all unique?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am running into a problem and I have yet to find an elegant solution for it.

I have three fields in a database that cannot have duplicates of these particular fields.

+----------+-------------------+----------------+
| hostname | mac               | ip             |
+----------+-------------------+----------------+
| pmac-1   | 00:30:65:6c:ea:cc | 128.110.22.15  |
+----------+-------------------+----------------+
| pmac-2   | 00:30:65:6c:e0:cc | 128.110.22.16  |
+----------+-------------------+----------------+

Now I have a simple form that opens up a record and allows users to modify 2 of the 3 fields, mac & ip.

In order for the user to save the record and overwrite the current contents of the database I first need to do a check to see if any of the 2 fields being updated match an existing record.

For example say the user modifies the ip field from 128.110.22.15 to 128.110.22.16, because there is an entry that matches that change the record does not update, or vice versa for the mac fields.

Has anyone every performed such a feat as to check for matching fields before updating? And if so could you show me some code that used to accomplish this. I have written my own but the if - else statements are getting ridiculous.

Thanks,
jas

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux