MetaModels\DcGeneral\Data\Driver::isUniqueValue PHP Method

isUniqueValue() public method

Determine if a given value is unique within the metamodel.
public isUniqueValue ( string $strField, mixed $varNew, integer $intId = null ) : boolean
$strField string The attribute name.
$varNew mixed The value that shall be checked.
$intId integer The (optional) id of the item currently in scope - pass null for new items.
return boolean True if the values is not yet contained within the table, false otherwise.
    public function isUniqueValue($strField, $varNew, $intId = null)
    {
        $attribute = $this->getMetaModel()->getAttribute($strField);
        if ($attribute) {
            $matchingIds = $this->prepareFilter($this->getEmptyConfig()->setFilter(array(array('operation' => '=', 'property' => $attribute->getColName(), 'value' => $varNew))))->getMatchingIds();
            return count($matchingIds) == 0 || $matchingIds == array($intId);
        }
        return false;
    }