The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate Across Columns
#1
Hi, all,
Is there any way to use the Validate class to verify if a combination of values is unique across multiple columns? I mean, in the same way that composite primary keys need to be unique. Or, will I have to do that a different way?
Thanks for the help,
Tim Meredith
  Reply
#2
The validate class won't do that by itself, so basically you'll have to run a query like

Code:
$checkQ = $db->query("SELECT * FROM users WHERE
.... //fill in your conditions here

Code:
$checkC = $checkQ->count();
//get a count of the results

Code:
if($checkC < 1) {
//No results found, therefore it is unique)
//do something
Code:
}
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)