Query and fetch

@param $sql
@return array|int
545950
public function queryAndFetch($sql) {
		$q = $this->query($sql);
		if (empty($q)) {
			return array();
		}
		$res = array();
		while ($l = ($this->fetch($q))) {
			$res[] = $l;
		}
		return $res;
	}
481564
final public static function findBySql (string $sql) : array
	{
        $dbObject 		= Database::getInstance();
		$resultSet 		= $dbObject->query($sql);
		$objectArray 	= [];
		while ($row = Database::fetchAssoc($resultSet))
		{
			$objectArray[] = static::instantiate($row);
		}
		return $objectArray;
	}
1095061
public function query($sql)
    {
        return $this->getDisconnectRetry()->run(function () use ($sql) {
            $statement = $this->prepare($sql);
            $statement->execute();

            return $statement;
        });
    }
266547
public function selectValues($sql)
    {
        $result = $this->execute($sql);
        if ($result->count()) {
            $values = [];
            foreach ($result as $row) {
                $values[] = reset($row);
            }
            return $values;
        }
    }
555583
protected function fetch( $sql, $params = null ) {
		$stmt = $this->dbh->prepare( $sql );
		$this->bind( $stmt, $params );
		$stmt->execute();
		return $stmt->fetch();
	}
1202330
public static function fetchAll($conn, $sql) {
    $conn = is_array($conn) ? self::connect($conn) : $conn;
    $result = $conn->query($sql);
    if (!$result) {
      throw new SqlException("Cannot execute $sql: " . $conn->error);
    }

    $rows = array();
    while ($row = $result->fetch_assoc()) {
      $rows[] = $row;
    }
    $result->free_result();

    return $rows;
  }
248817
protected function getOrderBySql(array $sql): array
    {
        if (empty($this->orderBy)) {
            return $sql;
        }
        $sql[] = 'ORDER BY ' . implode(', ', $this->quoter->quoteByFields($this->orderBy));

        return $sql;
    }
719647
public function fetchValue($sql, array $parameters = [])
    {
        $statement = $this->executeQuery($sql, $parameters);

        return $statement->fetchColumn(0);
    }
963217
public function query($sql)
    {
        $result = $this->pdo->query($sql);
        $this->executed[] = $sql;
        return $result;
    }
435408
public function queryValues(string $sql, string $key): array
    {
        $result = [];
        $statement = $this->query($sql);
        while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
            $result[] = $row[$key];
        }

        return $result;
    }
826061
public function fetch_array($sql)
    {
        $rs   = $this->query($sql);
        $data = mysql_fetch_assoc($rs);
        if (empty($data)) {
            $data = [];
        }

        mysql_free_result($rs);
        return $data;
    }
1036518
public function fetchOne($sql, $values = null, $connection = null)
  {
    $st = $this->query($sql, $values, $connection);

    return $st->fetch(\PDO::FETCH_ASSOC);
  }
581791
protected function query($sql) {
		$this->sqlCnt++;
		$res = $this->db->query($sql);
		if (!$res) {
			$this->dbError = $this->db->error;
		}
		return $res;
	}
769131
function fetch_object($sql)
    {
        $rs   = $this->query($sql);
        $data = $rs->fetch_object();

        $rs->free(); //释放内存
        return $data;
    }
76473
public function fetchAll(string $sql, array $params = []) : array
    {
        $result = $this->query($sql, $params, true);

        $return = [];

        foreach ($result as $item) {
            $return[] = $item;
        }

        return $return;
    }
189079
public function fetch_assoc($sql)
    {

        if (empty($sql)) return false;

        $res    = $this->query($sql);
        $result = @mysql_fetch_assoc($res);
        $this->free($res);

        return $result;
    }
444532
public static function count($sql)
    {
        $data = self::query($sql);
        $result = $data->fetchAll(PDO::FETCH_ASSOC);
        //
        return  $result ? count($result) : -1;
    }