根据关联条件查询当前模型
@access public
@param string  $operator 比较操作符
@param integer $count    个数
@param string  $id       关联表的统计字段
@param string  $joinType JOIN类型
@return Query
180163
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
    {
        $table    = $this->query->getTable();
        $model    = basename(str_replace('\\', '/', get_class($this->parent)));
        $relation = basename(str_replace('\\', '/', $this->model));

        return $this->parent->db()
            ->alias($model)
            ->field($model . '.*')
            ->join($table . ' ' . $relation, $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType)
            ->group($relation . '.' . $this->foreignKey)
            ->having('count(' . $id . ')' . $operator . $count);
    }
872740
protected function addHasWhere( Builder $hasQuery, Relation $relation, $operator, $count, $boolean )
	{
		$hasQuery->mergeModelDefinedRelationConstraints( $relation->getQuery() );

		if ( $this->shouldRunExistsQuery( $operator, $count ) )
		{
			$not = ( $operator === '<' && $count === 1 );

			return $this->addWhereExistsQuery( $hasQuery->toBase(), $boolean, $not );
		}

		return $this->whereCountQuery( $hasQuery->toBase(), $operator, $count, $boolean );
	}
1062394
public function rawSelectById($id, Query $query = null, $join = 'all')
        {
            if (!$id) {
                return null;
            }

            if (!$query instanceof Query) {
                $query = new Query($this);
            }
            $query->where($this->id_column, $id);
            $query->setLimit(1);
            return $this->rawSelectOne($query, $join);
        }
925841
public function join($table, $key_one, $operator, $key_two = null)
    {
        if (is_null($key_two)) {
            $key_two = $operator;
            $operator = '=';
        }

        $this->joins .= " JOIN {$table} ON {$key_one} {$operator} {$key_two} ";

        return $this;
    }
866553
public int queryObjJoinCountByCondition(String sql){
		/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
		.getDbSource(dbName);*/
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		logger.debug(sql);
		Integer total=jdbcTemplate.queryForObject(sql,Integer.class);
		return total;
	}
631816
public QueryBuilder<T, ID> join(QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation)
			throws SQLException {
		addJoinInfo(type, null, null, joinedQueryBuilder, operation);
		return this;
	}
11351
public function join($foreign, $on, $joinType = Joins::INNER)
    {
        $builder = $this->getJoinStatement()->getBuilder();
        $foreign = is_array($foreign) ? $foreign : [$foreign];
        $foreign[0] = !($foreign[0] instanceof Expression) ? new Table($foreign[0]) : $foreign[0];
        
        $foreign = $builder->completeExpression(...$foreign);
        
        if (is_array($on)) {
            $whereOn = new Statement\Where($builder);
            $on = count($on) === count($on, true) ? [$on] : $on;
            
            foreach ($on as $criteria) {
                list($criteria[0], $criteria[1]) = [
                    ($criteria[0] instanceof Expression) ? $criteria[0] : $builder->createColumn($criteria[0]),
                    ($criteria[1] instanceof Expression) ? $criteria[1] : $builder->createColumn($criteria[1]),
                ];
                $whereOn->where(...$criteria);
            }
            
            $on = $whereOn;
        }
        
        $this->addJoin($foreign, $on, $joinType);
        
        return $this;
    }
1089138
public static function where($column, $operator = null, $value = null, $type = " AND ")
    {
        return self::getInstance()->whereExecute($column, $operator, $value, $type);
    }
847533
protected function aggregate($column, $operator, $db)
    {
        if (!empty($this->emulateExecution)) {
            return null;
        }

        $this->prepare();
        $collection = $this->getCollection($db);
        $pipelines = [];
        if ($this->where !== null) {
            $pipelines[] = ['$match' => $this->where];
        }
        $pipelines[] = [
            '$group' => [
                '_id' => '1',
                'total' => [
                    '$' . $operator => '$' . $column
                ],
            ]
        ];
        $result = $collection->aggregate($pipelines);
        if (array_key_exists(0, $result)) {
            return $result[0]['total'];
        }
        return null;
    }
885812
public static function findById (int $id, string $operator="=", int $limit=1)
	{
        $id 		= Database::getInstance()->escapeValue($id);
		$operator 	= static::validateOperator($operator, '=');
		return static::limitFindBySql("SELECT * FROM ".static::$tableName." WHERE id {$operator} {$id}", $limit);
	}
77434
public function where(string $column, $operator = null, $value = null): BaseQueryRelateContract
    {
        $this->query->where($column, $operator, $value);

        return $this;
    }
648322
public int queryObjJoinCountByCondition(String sql,Object[] paramArray){
		/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
		.getDbSource(dbName);*/
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		logger.debug(sql);
		logger.debug(Arrays.toString(paramArray));
		Integer total=jdbcTemplate.queryForObject(sql,Integer.class,paramArray);
		return total;
	}
991309
public function where($column, $operator = null, $value = null, $boolean = 'and')
    {
        // Tratar alias do _id
        $column = ($column == 'id') ? '_id' : $column;

        // Here we will make some assumptions about the operator. If only 2 values are
        // passed to the method, we will assume that the operator is an equals sign
        // and keep going. Otherwise, we'll require the operator to be passed in.
        list($value, $operator) = $this->prepareValueAndOperator(
            $value, $operator, func_num_args() == 2
        );

        // If the columns is actually a Closure instance, we will assume the developer
        // wants to begin a nested where statement which is wrapped in parenthesis.
        // We'll add that Closure to the query then return back out immediately.
        if ($column instanceof Closure) {
            return $this->whereNested($column, $boolean);
        }

        // If the given operator is not found in the list of valid operators we will
        // assume that the developer is just short-cutting the '=' operators and
        // we will set the operators to '=' and set the values appropriately.
        if ($this->invalidOperator($operator)) {
            list($value, $operator) = [$operator, '='];
        }

        // If the value is a Closure, it means the developer is performing an entire
        // sub-select within the query and we will need to compile the sub-select
        // within the where clause to get the appropriate query record results.
        // BRUNO-AKI
        //if ($value instanceof Closure) {
        //    return $this->whereSub($column, $operator, $value, $boolean);
        //}

        // If the value is "null", we will just assume the developer wants to add a
        // where null clause to the query. So, we will allow a short-cut here to
        // that method for convenience so the developer doesn't have to check.
        if (is_null($value)) {
            return $this->whereNull($column, $boolean, $operator !== '=');
        }

        // Now that we are working with just a simple query we can put the elements
        // in our array and add the query binding to our array of bindings that
        // will be bound to each SQL statements when it is finally executed.
        $type = 'Basic';

        $this->wheres[] = compact(
            'type', 'column', 'operator', 'value', 'boolean'
        );

        return $this;
    }
1231556
public function join(string $table, string $one, string $operator = '=', string $two = ''): BaseQueryRelateContract
    {
        $this->query->join($table, $one, $operator, $two);

        return $this;
    }
654918
public function has($relation, $operator = '>=', $count = 1)
    {
        $this->hasRelations[$relation] = [$operator, $count];

        return $this;
    }
1090738
protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName, $joinType)
    {
        $script .= "
    /**
     * Adds a JOIN clause to the query using the " . $relationName . " relation
     *
     * @param     string \$relationAlias optional alias for the relation
     * @param     string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return " . $queryClass . " The current query, for fluid interface
     */
    public function join" . $relationName . "(\$relationAlias = null, \$joinType = " . $joinType . ")
    {
        \$tableMap = \$this->getTableMap();
        \$relationMap = \$tableMap->getRelation('" . $relationName . "');

        // create a ModelJoin object for this join
        \$join = new ModelJoin();
        \$join->setJoinType(\$joinType);
        \$join->setRelationMap(\$relationMap, \$this->useAliasInSQL ? \$this->getModelAlias() : null, \$relationAlias);
        if (\$previousJoin = \$this->getPreviousJoin()) {
            \$join->setPreviousJoin(\$previousJoin);
        }

        // add the ModelJoin to the current object
        if (\$relationAlias) {
            \$this->addAlias(\$relationAlias, \$relationMap->getRightTable()->getName());
            \$this->addJoinObject(\$join, \$relationAlias);
        } else {
            \$this->addJoinObject(\$join, '" . $relationName . "');
        }

        return \$this;
    }
";
    }
774682
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
	{
		$relation = $this->getHasRelationQuery($relation);

		$query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);

		if ($callback) call_user_func($callback, $query);

		return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
	}