执行count聚簇函数
@param string $field
@return int|false 如果成功则返回相应的值；SQL执行发生错误则返回false
171976
public function count($field = '*') {
        $this->statementContext->setFields("COUNT({$field}) AS __COUNT__");
        $row = $this->findOne();

        //SQL执行发生错误
        if ($row === false) {
            return false;
        }

        return $row['__COUNT__'];
    }
137192
public function get(string $field)
    {
        if ($field === "secure")
            return $this->scheme === "https";

        if ($field === "port" && $this->port === null)
        {
            if ($this->scheme === "http") return 80;
            if ($this->scheme === "https") return 443;
            if ($this->scheme === "ftp") return 21;
        }

        if ($field === "suffix")
            return $this->getSuffix();
                
        if ($field === "query")
            return $this->getQuery();

        if (property_exists($this, $field))
            return $this->$field;

        throw new \OutOfRangeException($field);
    }
53753
protected function append($fields, string $field)
    {
        // 转换为字段列表
        $fields = $this->table->createFields($fields);

        // 如果是*,不用附加了
        if ($fields == '*') {
            return $fields;
        }

        // 分解为数组
        $fieldsArr = explode(',', $fields);

        // 如果要附加的字段已经在里面了
        if (in_array($field, $fieldsArr)) {
            return $fields;
        }

        // 附加一个字段
        $fieldsArr[] = $field;

        // 返回字段数组
        return $fieldsArr;
    }
884439
public function inc($field, $num = 1, $return = Db::RETURN_ISOK)
	{
		$data = array ();
		// 参数都在field
		if (is_array($field))
		{
			// 数组参数，多个
			foreach ($field as $key => $value)
			{
				$f = $this->db->parseKeyword($key);
				$data = "{$f}={$f}+{$value}";
			}
		}
		else
		{
			// 单个单数
			$f = $this->db->parseKeyword($field);
			$data = "{$f}={$f}+{$num}";
		}
		$this->db->operationOption = $this->getOption();
		return $this->db->update($data, $return);
	}
932521
public function count($table, $cond=null, $fields='*', $distinct=false)
    {
    	$ds = $this->ds();
    	if ($distinct) $distinct = 'DISTINCT ';
    	
    	$cond = SqlHelper::parse_cond($ds,$cond);
    	if ($cond) $cond = "WHERE {$cond}";
		
    	if (is_null($fields) || trim($fields) == '*') {
            $fields = '*';
        } 
        else {
            $fields = SqlHelper::qfields($fields,$table);
        }
        
        $table = SqlHelper::qtable($table);
        
        $result = (int) Sql::read($ds, Sql::MODE_READ_GETONE, [
				"SELECT COUNT({$distinct}{$fields}) FROM {$table} {$cond}"
			]);
		return $result;
    }
477507
public function count(string $column = '*'): int
    {
        $count = $this->queryRelate->getQuery()->count($column);

        $this->resetQueryRelate();

        return $count;
    }
522626
public function column($field)
    {
        $query = clone $this->_queryForWrite();

        return $query->select($field)->execute()->column($field);
    }
696982
public function get($index = 0, $field = null) {
        if ($this->performed) {
            if (is_numeric($index)) {
                $index = intval($index);
            } else if (is_string($index)) {
                $field = $index;
                $index = 0;
            } else {
                return null;
            }
        } else {
            if (is_array($index)) {
                return $this->where($index);
            }

            if (is_numeric($index)) {
                $index = intval($index);
            } else if (is_string($index)) {
                $field = $index;
                $this->field($field);
                $index = 0;
                $this->limit(0, 1);
            } else {
                $index = 0;
            }
            $this->select();
        }
        if (isset ($this->resultSets [ $index ])) {
            $row = $this->resultSets [ $index ];
            if ($field != null && isset ($row [ $field ])) {
                return $row [ $field ];
            }
            if ($field == null) {
                return $row;
            }
        }

        return null;
    }
1336298
public function total($field = '*') {
        if (!$this->countperformed || $this->whereData) {
            $this->performCount('*');
        }

        return $this->count;
    }
360716
public function fetchCount($field = '')
    {
        $opts = $this->options;
        
        if ($field) {
            $opts['field'] = $field;
        } else {
            $opts['field'] = '*';
        }
        
        $sql = \wf\db\QueryBuilder::optionsToCountSql($opts);
        $num = $this->getDb()->getColumn($sql);
        
        return $num;
        
    }
956059
private function _count($method, $column = NULL)
    {
        $this->options['limit']['0'] = 1;
        if($method == 'distinct')
            if(is_null($column)) // 默认id
                $this->options['field']['0'] = 'count(' . $method . ' `' . $this->key . '`) as count';
            else
                $this->options['field']['0'] = 'count(' . $method . ' `' . $column . '`) as count';
        elseif(is_null($column) && $method == 'count') // 默认*
            $this->options['field']['0'] = $method . '(*) as count';
        elseif($column)
            $this->options['field']['0'] = $method . '(`' . $column . '`) as count';
        else // 默认id
            $this->options['field']['0'] = $method . '(`' . $this->key . '`) as count';
        $result = $this->query($this->_parseSql(), $this->prepareParam, false);
        return isset($result->count) ? $result->count : 0;
    }
1233560
public function count($field = '*')
    {
        if ($this->_union) {
            throw new NotSupportedException('Union query is not support to get total rows');
        }

        $copy = clone $this;

        $copy->_fields = "COUNT($field) as [row_count]";
        $copy->_limit = null;
        $copy->_offset = null;
        $copy->_order = null;
        $copy->_index = null;

        $copy->_sql = $copy->_buildSql();

        if ($copy->_group === null) {
            $result = $copy->getConnection()->fetchOne($copy->_sql, $copy->_bind);

            /** @noinspection CallableParameterUseCaseInTypeContextInspection */
            $rowCount = (int)$result['row_count'];
        } else {
            $result = $copy->getConnection()->fetchAll($copy->_sql, $copy->_bind);
            $rowCount = count($result);
        }

        return $rowCount;
    }
747627
private function performCount($field = '*') {
        try {
            $this->checkDialect();
        } catch (DialectException $e) {
            $this->error          = $e->getMessage();
            $this->count          = 0;
            $this->errorSQL       = '';
            $this->errorValues    = null;
            $this->countperformed = true;

            return;
        }
        $this->count = false;
        $values      = new BindValues ();
        $fields [0]  = 'COUNT(' . $field . ')';
        $fields      = $this->prepareFields($fields, $values);
        $from        = $this->prepareFrom($this->sanitize($this->from));
        $joins       = $this->prepareJoins($this->sanitize($this->joins));
        $having      = $this->sanitize($this->having);
        $group       = $this->sanitize($this->group);
        $sql         = $this->dialect->getCountSelectSQL($fields, $from, $joins, $this->where, $having, $group, $values);
        if ($sql) {
            try {
                $this->options [ \PDO::ATTR_CURSOR ] = \PDO::CURSOR_SCROLL;
                $statement                           = $this->dialect->prepare($sql, $this->options);
                if ($values) {
                    foreach ($values as $value) {
                        list ($name, $val, $type, $field) = $value;
                        if ($this->whereData) {
                            $val = isset($this->whereData[ $field ]) ? $this->whereData[ $field ] : (isset($this->whereData[ $name ]) ? $this->whereData[ $name ] : $val);
                        }
                        if (!$statement->bindValue($name, $val, $type)) {
                            $this->countperformed = true;
                            $this->count          = 0;
                            $this->errorSQL       = $sql;
                            $this->errorValues    = $values->__toString();
                            $this->error          = 'can not bind the value ' . $val . '[' . $type . '] to the argument:' . $name;

                            return;
                        }
                    }
                }
                $rst = $statement->execute();
                QueryBuilder::addSqlCount();
                if ($rst) {
                    $resultSet = $statement->fetch(\PDO::FETCH_NUM);
                    $statement->closeCursor();
                    $this->count = intval($resultSet [0]);
                } else {
                    $this->dumpSQL($statement);
                }
            } catch (\PDOException $e) {
                $this->error       = $e->getMessage();
                $this->count       = 0;
                $this->errorSQL    = $sql;
                $this->errorValues = $values->__toString();
            }
        } else {
            $this->count       = 0;
            $this->errorSQL    = '';
            $this->errorValues = $values->__toString();
            $this->error       = 'can not generate the SQL';
        }
        $this->countperformed = true;
    }
939193
public function count() {
        $sql    = $this->getSQL();
        $values = $this->values;
        if ($sql) {
            try {
                $statement = $this->dialect->prepare($sql);
                foreach ($values as $value) {
                    list ($name, $val, $type) = $value;
                    if (!$statement->bindValue($name, $val, $type)) {
                        $this->errorSQL    = $sql;
                        $this->errorValues = $values->__toString();
                        $this->error       = 'can not bind the value ' . $val . '[' . $type . '] to the argument:' . $name;

                        return false;
                    }
                }
                $rst = $statement->execute();
                $cnt = false;
                if ($rst) {
                    $cnt = $statement->rowCount();
                } else {
                    $this->dumpSQL($statement);
                }
                if ($statement) {
                    $statement->closeCursor();
                    $statement = null;
                }
                QueryBuilder::addSqlCount();

                return $cnt;
            } catch (\PDOException $e) {
                $this->exception   = $e;
                $this->error       = $e->getMessage();
                $this->errorSQL    = $sql;
                $this->errorValues = $values->__toString();

                return false;
            }
        } else {
            $this->error       = 'Can not generate the delete SQL';
            $this->errorSQL    = '';
            $this->errorValues = $values->__toString();
        }

        return false;
    }
419066
public function count($field = '*')
    {
        $field = $this->distinct ? "DISTINCT {$field}" : $field;
        return intval($this->select(new Raw("COUNT({$field}) as `aggregation`"))->first(1)->aggregation);
    }
403335
public function count($field = null)
    {
        // when no field is given we use *
        if (is_null($field))
        {
            $field = new Expression('*');
        }

        // return the column
        return (int) $this->column(new Func('count', $field));
    }
322053
public function countAll($column = '*')
    {
        $results = $this->db->get($this->table, NULL, $column);

        return (int) count($results);
    }