@param string $className
@param string $column
@param array  $condition

@return ResultInterface
508040
public static function count(string $className, string $column, array $condition): ResultInterface
    {
        $instance = self::getInstance($className);
        $query    = Query::table($className)->selectInstance($instance)->condition($condition);

        return $query->count($column);
    }
1330558
function delete($condition = '', $params = []) {
        $sql = "DELETE FROM `$this->table`";

        if($this->where) {
            $sql .= ' '.$this->where;
        }

        if ($condition) {
            if(is_array($condition)) {
                $sql .= $this->w . $this->parseWhere($condition[0]);
            }
            elseif ($params) {
                //using prepared statement.
                if (!is_array($params)) {
                    $params = [$params];
                }
                $sql .= $this->w . $condition;
                $this->params = array_merge($this->params, $params);
            }
            else {
                $sql .= $this->w . $condition;
            }
        }

        $sql = str_replace('table.',$this->table.'.',$sql);
        $params = $this->params;

        $this->_reset();

        return $this->execute($sql, $params,false);
    }
833268
protected function findIndexesForTableConditions(
        array $conditions,
        TableInterface $table,
        $tableName
    ) {
        $indexes = array();

        /* @var $tableSchema TableSchema */
        $tableSchema = $table->getTableSchema();

        $conditionColumns = array();

        foreach ($conditions as $condition) {
            /* @var $condition ConditionJob */

            $column = $condition->getFirstParameter();
            $fixedValue = $condition->getLastParameter();

            if ($fixedValue instanceof ColumnSpecifier) {
                list($column, $fixedValue) = [$fixedValue, $column];
            }

            if ($column instanceof ColumnSpecifier) {
                /* @var $column ColumnSpecifier */

                if (is_null($column->getTable()) || $column->getTable() === $tableName) {
                    $columnId = $tableSchema->getColumnIndex($column->getColumn());

                    if (is_int($columnId) && $columnId >= 0) {
                        $conditionColumns[$column->getColumn()] = $columnId;
                    }
                }
            }
        }

        if (!empty($conditionColumns)) {
            foreach ($tableSchema->getIndexIterator() as $indexId => $indexSchema) {
                /* @var $indexSchema IndexSchema */

                $indexColumns = $indexSchema->getColumns();

                if (empty(array_diff($indexColumns, $conditionColumns))) {
                    /* @var $index IndexInterface */
                    $index = $table->getIndex($indexId);

                    $indexes[] = $index;
                }
            }
        }

        return $indexes;
    }
1150814
public function update($table, $columns, $condition = [], array $params = [])
    {
        $request = $this->db->getQueryBuilder()->update($table, $columns, $condition, $params);

        return $this->setRequest($request);
    }
296781
public static function whereAndClause($tableName, $data, $condition)
    {
        $where = "";
        $counter = 0;
        $arraySize = count($data);

        if ($data !== null) {
            foreach ($data as $key => $value)
            {
                $counter++;
                $columnName = self::checkColumn($tableName, self::sanitize($key));
                $where .= $tableName.'.'.$columnName ." = '".self::sanitize($value)."'";
                if ($arraySize > $counter)
                {
                    $where .= " " . $condition . " ";
                }
            }
        } else {
            $where = "";
        }

        return $where;
    }
1365320
public static function findById($className, $id, array $options): ResultInterface
    {
        list($tableName, , $columnId) = self::getTable($className);
        $instance = self::getInstance($className);

        $query = Query::table($tableName)->className($className)->where($columnId, $id)->selectInstance($instance)->addDecorator(function ($result) {
            if (isset($result[0])) {
                return $result[0];
            }

            return null;
        });

        $options['limit'] = 1;
        $query            = self::applyOptions($query, $options);
        $fields           = self::getFieldsFromOptions($options);

        return $query->get($fields);
    }
329693
public function where(array $condition = null): Select
    {
        if (!\is_array($condition)) {
            throw new InvalidArgumentException('$condition has to be an array');
        }
        $this->where = (new Condition($this->namesClass->getAliases()))->parse($condition);

        return $this;
    }
683843
public function asObject(string $className, array $constructorArgs = []): QueryBuilderHandler
    {
        return $this->setFetchMode(PDO::FETCH_CLASS, $className, $constructorArgs);
    }
78694
public function fetchRow(array $where = null, array $column = null, array $order = null)
    {
        $qp = $this->_fetch($where, $column, $order);

        $row = $this->_fetchRow($qp['query'], $qp['params']);
        $className = $this->_rowClass;
        $class = new $className($this);

        if (!$row) {
            return false;
        }

        $class->setData($row);

        return $class;
    }
246958
public function create($className)
    {
        $builder = new Builder($className, $this);
        $this->getGuesser()->fill($builder);
        return $builder;
    }
145070
public function getConditionSql(array $sql, array $where, string $conditionType): array
    {
        if (empty($where)) {
            return $sql;
        }
        foreach ($where as $index => $item) {
            if ($item instanceof RawExp) {
                if ($index == 0) {
                    $sql[] = $conditionType . ' ' . $item->getValue();
                    continue;
                }
                $sql[] = $item->getValue();
                continue;
            }
            [$type, $conditions] = $item;
            if (!$index) {
                $whereType = $conditionType;
            } else {
                $whereType = strtoupper($type);
            }
            if ($conditions[0] instanceof RawExp) {
                $sql[] = $whereType . ' ' . $conditions[0]->getValue();
                continue;
            }
            [$leftField, $operator, $rightField] = $conditions;
            $leftField = $this->quoter->quoteName($leftField);
            [$rightField, $operator] = $this->getRightFieldValue($rightField, $operator);

            $sql[] = sprintf('%s %s %s %s', $whereType, $leftField, $operator, $rightField);
        }

        return $sql;
    }
1240521
public function condition($inputs)
    {
        $value = array_get($inputs, $this->column);

        if (is_null($value)) {
            return;
        }

        $this->value = $value;

        return $this->buildCondition($this->column, '>=', $this->value);
    }
614759
public function condition($inputs)
    {
        if (!Arr::has($inputs, $this->column)) {
            return;
        }

        $this->value = Arr::get($inputs, $this->column);

        $value = array_filter($this->value, function ($val) {
            return $val !== '';
        });

        if (empty($value)) {
            return;
        }

        if (!isset($value['start'])) {
            return $this->buildCondition($this->column, '<=', $value['end']);
        }

        if (!isset($value['end'])) {
            return $this->buildCondition($this->column, '>=', $value['start']);
        }

        $this->query = 'whereBetween';

        return $this->buildCondition($this->column, $this->value);
    }
695498
public static function updateAll(string $className, array $attributes, array $condition)
    {
        $instance = self::getInstance($className);

        return Query::table($className)->selectInstance($instance)->condition($condition)->update($attributes);
    }
1137489
public function queryObjArray($query, $className, $options = array(), $classConstructorArguments = NULL)
    {
        if (!class_exists($className)) {
            $this->_error(FQDBException::CLASS_NOT_EXIST, FQDBException::FQDB_CODE);
        }

        return $this->queryArray($query, $options,
            function(\PDOStatement $statement) use ($className, $classConstructorArguments) {
                return $statement->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE,
                    $className, $classConstructorArguments);
            }
        );
    }
2837
public function query($column = null, $mode = null)
    {
        if (is_null($mode)) {
            $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE);
        }

        $result = array();
        $rows = $this->getStmt()->fetch($mode);

        if ($column !== null) {
            if (isset($rows[$column])) {
                $result = $rows[$column];
            } else {
                $result = false;
            }
        } else {
            $result = $rows;
        }

        if ($this->relationProcessor->hasQueue()) {
            $data = $this->relationProcessor->process(array($result));
            return isset($data[0]) ? $data[0] : false;
        }

        // By default
        return $result;
    }
379050
public function condition($inputs)
    {
        if (!array_has($inputs, $this->column)) {
            return;
        }

        $this->value = array_get($inputs, $this->column);

        $value = array_filter($this->value, function ($val) {
            return '' !== $val;
        });

        if (empty($value)) {
            return;
        }

        if (!isset($value['start'])) {
            return $this->buildCondition($this->column, '<=', $value['end']);
        }

        if (!isset($value['end'])) {
            return $this->buildCondition($this->column, '>=', $value['start']);
        }

        $this->query = 'whereBetween';

        return $this->buildCondition($this->column, $this->value);
    }