protected function _checkUniqueness(QDB_ActiveRecord_Abstract $obj, QDB_Cond $more_cond = null, $ignore_id = false) { $check_props = Q::normalize($this->_settings['check_props']); if (empty($check_props)) { return; } $checks = array(); $error = array(); foreach ($check_props as $check) { if ($ignore_id && $check == $obj->idname()) { continue; } if (strpos($check, '+') !== false) { $props = Q::normalize($check, '+'); $cond = array(); foreach ($props as $prop_name) { $cond[$prop_name] = $obj->{$prop_name}; } } else { $cond = array($check => $obj->{$check}); $props = $check; } if (!is_null($more_cond)) { $cond[] = $more_cond; } $test = $this->_meta->find($cond)->count()->query(); if ($test['row_count'] < 1) { continue; } if (isset($this->_settings['error_messages'][$check])) { $error[$check] = array($check => $this->_settings['error_messages'][$check]); } else { $error[$check] = array($check => "{$check} duplicated"); } } if (!empty($error)) { throw new QDB_ActiveRecord_ValidateFailedException($error, $obj); } }