Check if the given input is unique in the given database table and column.

@param $input
@param $table
@param $column
179258
protected function unique($input, $table, $column)
    {
        $email = $this->db->get($table, $column, [
            $column => $input
        ]);
        if ($email) {
            var_dump("error: {$column} not unique");
            $this->failed = true;
        }
    }
158226
@Override
    protected boolean i_updateRow(Connection conn,
                                  String table,
                                  String[] columns,
                                  String[] values,
                                  String uniqueColumn,
                                  boolean[] numeric) throws SQLException {

        // prepare update statement
        StringBuilder sql = new StringBuilder(64);
        sql.append("UPDATE ").append(table).append(" SET ");
        boolean needComma = false;
        for (int i = 0; i < columns.length; i++) {
            if (!columns[i].equals(uniqueColumn)) {
                if (needComma) {
                    sql.append(", ");
                } else {
                    needComma = true;
                }
                sql.append(columns[i] + " = ");
                if (values[i] == null) {
                    sql.append("NULL");
                } else {
                    sql.append('?');
                }
            }
        }
        sql.append(" WHERE ");
        sql.append(uniqueColumn);
        sql.append(" = ?");
        if (logger.isDebugEnabled()) {
            logger.debug("About to execute: " + sql.toString());
        }
        PreparedStatement stmt = conn.prepareStatement(sql.toString());

        try {
            // populate values
            int varIndex = 0;
            for (int i = 0; i < columns.length; i++) {
                if (!columns[i].equals(uniqueColumn) && values[i] != null) {
                    varIndex++;
                    if (numeric != null && numeric[i]) {
                        setNumeric(stmt, varIndex, columns[i], values[i]);
                    } else {
                        stmt.setString(varIndex, values[i]);
                    }
                }
            }
            varIndex++;
            stmt
                    .setString(varIndex, getSelector(columns,
                                                     values,
                                                     uniqueColumn));

            // execute and return true if existing row was updated
            return stmt.executeUpdate() > 0;

        } finally {
            closeStatement(stmt);
        }
    }
1114896
private static function other($column, array $unique)
    {
        $definition = '';

        // size
        if (null !== $column->scale && 0 < $column->scale) {
            $definition .= "($column->precision,$column->scale)";

        } elseif (null !== $column->size && !$column->autoIncrement && 'tinyint(1)' !== $column->dbType) {
            $definition .= "($column->size)";

        } elseif (null !== $column->size && !$column->isPrimaryKey && $column->unsigned) {
            $definition .= "($column->size)";
        }

        // unsigned
        if ($column->unsigned) {
            $definition .= '->unsigned()';
        }

        // null
        if ($column->allowNull) {
            $definition .= '->null()';

        } elseif (!$column->autoIncrement) {
            $definition .= '->notNull()';
        }

        // unique key
        if (!$column->isPrimaryKey && !empty($unique)) {
            foreach ($unique as $name) {
                if (reset($name) === $column->name) {
                    $definition .= '->unique()';
                }
            }
        }

        // default value
        if ($column->defaultValue instanceof Expression) {
            $definition .= "->defaultExpression('$column->defaultValue')";

        } elseif (is_int($column->defaultValue)) {
            $definition .= "->defaultValue($column->defaultValue)";

        } elseif (is_bool($column->defaultValue)) {
            $definition .= '->defaultValue('.var_export($column->defaultValue, true).')';

        } elseif (is_string($column->defaultValue)) {
            $definition .= "->defaultValue('".addslashes($column->defaultValue)."')";
        }

        // comment
        if (null !== $column->comment && '' !== $column->comment) {
            $definition .= "->comment('".addslashes($column->comment)."')";
        }

        // append

        return $definition;
    }
821378
protected function validate($input, array &$messages)
    {
        $uniqueValues = [];

        foreach ($input as $element) {
            $uniqueValues[ValueHasher::hash($element)] = true;
        }

        if (count($uniqueValues) !== count($input)) {
            $messages[] = new Message(self::MESSAGE);
        }
    }
307815
protected function setColumn($column)
    {
        if ($column instanceof ColumnMap) {
            $this->column = $column->getName();
            $this->table = $column->getTable()->getName();
        } else {
            $dotPos = strrpos($column, '.');
            if ($dotPos === false) {
                // no dot => aliased column
                $this->table = null;
                $this->column = $column;
            } else {
                $this->table = substr($column, 0, $dotPos);
                $this->column = substr($column, $dotPos + 1, strlen($column));
            }
        }
    }
1005236
public function check($table, $colname, $val){
    $oldvals = $this->readdb($table, $colname);

        if($oldvals && is_array($oldvals)){
        $oldvals = array_flip($oldvals);
        }

        if(isset($oldvals[$val])){
        return true;
        }

    return false;
    }
1112848
public function addColumn(Column $column)
    {
        $columns = func_get_args();

        foreach ($columns as $column) {
            $this->columns[$column->columnName] = $column;

            if ($column instanceof AutoIncrementColumn) {
                $this->uniqueIdentifierColumnName = $column->columnName;
            }
        }
    }
883513
public function hasIndex($columns, $unique=false)
    {
        if (!is_array($columns)) {
            $columns = array($columns);
        }
        foreach ($this->getIndexes() as $index) {
            if ($index->isUnique() == $unique and $index->getColumns() == $columns) {
                return true;
            }
        }
        return false;
    }
1029396
final public function distinct($column)
    {
        if (!is_array($column)) {
            $column = explode(',', $column);
        }
        $column = array_map([$this, 'formatColumn'], $column);

        $this->_sql['distinct'] = array_merge($this->_sql['distinct'], $column);
        return $this;
    }
1247362
public function hasColumn($table, $column)
    {
        $column = strtolower($column);

        return in_array($column, array_map('strtolower', $this->getColumnListing($table)));
    }
918365
protected function addUniqueConstraint(Table $table)
    {
        $unique = new Unique($this->getColumnForParameter('slug_column'));
        $unique->setName($table->getCommonName() . '_slug');
        $unique->addColumn($table->getColumn($this->getParameter('slug_column')));
        if ($this->getParameter('scope_column')) {
            $unique->addColumn($table->getColumn($this->getParameter('scope_column')));
        }
        $table->addUnique($unique);
    }
1292171
public function prepare($input)
    {
        $form = $this->buildNestedForm($this->column, $this->builder);

        return $form->setOriginal($this->original, $this->getKeyName())->prepare($input);
    }
803694
public function validate_unique($field, $input, $param) {

        $qtInstance = qt_instance();
        $model = $qtInstance->modelFactory(strtoupper($param));
        
        $model->findOneBy($field, $input[$field]);
        
        if(empty($model->asArray())) {
            return NULL;
        }
        
        return array(
            'field' => $field,
            'value' => null,
            'rule' => __FUNCTION__,
            'param' => $param,
        );
    }
499293
public function distinct($column, array $criteria = array(),
            $return = Table::RETURN_MODEL) {
        $this->current = self::OP_SELECT;
        $this->setExpectedResult($return, true);
        $this->targetColumns($column);
        $this->query = 'SELECT DISTINCT `' . $this->name . '`.`' . Util::camelTo_($column) . '` as ' . Util::_toCamel($column) . ' FROM `' . $this->name . '` ' . $this->joinQuery;
        $this->where($criteria);

        return $this->execute();
    }
17320
private function checkUniqueHandler(EventHandler $input)
    {
        foreach ($this->handlers as $handler) {
            if ($handler === $input) {
                throw new RuntimeException();
            }
        }
    }
1174096
protected function remoteColumn($model, $column)
    {
        $table = $model::$table;
        //
        return !is_null($column) ? $column : $this->idKey($table);
    }
271830
public static function createIndex($table, $columns, $unique = false)
    {
        return Yii::$app->db->createCommand()
            ->createIndex($table .'_'.implode('-', (array) $columns) . '_idx', $table, $columns, $unique)
            ->execute();
    }