_table = $table; $this->_columns = $columns; $this->_current = $current; if (is_array($options) && !empty($options)) { $this->setOptions($options); } } public function isValid($value, $context = null) { $value = (string) $value; $this->_setValue($value); $db = $this->_table->getAdapter(); $where = $this->getWhere(); foreach ($this->_columns as $column) { $where[] = $db->quoteInto($column . ' = ?', $context[$column]); } if (isset($this->_current)) { $current = (array) $this->_current; $info = $this->_table->info(); foreach ($info['primary'] as $key => $column) { $where[] = $db->quoteInto($column . ' <> ?', $current[$key - 1]); } } $rowset = $this->_table->fetchAll($where); if ($rowset->count()) { $this->_error(self::NOT_UNIQUE); return false; } return true; } }