Skip to content

Instantly share code, notes, and snippets.

@walker
Created September 14, 2009 20:14
Show Gist options
  • Select an option

  • Save walker/186899 to your computer and use it in GitHub Desktop.

Select an option

Save walker/186899 to your computer and use it in GitHub Desktop.
/**
* Checks that a value is unique
*
* @param string $check Value to check
* @param string $field Field to check for value
* @return boolean Success
* @access public
*/
function _isUnique($check, $field) {
$conditions = array();
foreach($check as $c) {
$conditions[] = "$this->name.$field=\"" . addslashes($c) . "\"";
}
if(isset($this->data[$this->name][‘id’]))
{
$conditions[] = "$this->name.id<>\"".addslashes($this->data[$this->name]['id'])."\"";
}
$results = $this->find($conditions);
if(!empty($results))
{
return false;
} else {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment