@param string $sql
@param array  $params

@return string[][]|\Generator
167413
public function sqlGenerate(string $sql, array $params = []): \Generator
    {
        $stmt = $this->prepare($sql, $params);

        while ($record = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            yield $record;
        }
    }
805201
public function getPost($sql, $params)
    {
        $post = $this->findWhere("$sql", $params);
        return $post->setupPost($post);
    }
799335
public function selectRaw(string $sql, string ...$params)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->columnRaw($sql, ...$params);

        return $instance;
    }
332380
public function fetchAll($sql, array $params, array $options = array())
    {
        $result = $this->run($sql, $params)->fetchAll(PDO::FETCH_ASSOC);
        $this->prepareResults($result, $options);
        return empty($result) ? array() : (array) $result;
    }
325531
public function query($sql, $params = [], $options = [])
    {
        $conn = $this->getConn(!empty($options['forceMaster']) ? true : false);

        $stmt = $this->prepare($conn, $sql, $params);

        $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
        if ($rows === false) {
            $this->throwException();
        }
        if (!empty($options['getRow'])) {
            $rows = isset($rows[0]) ? $rows[0] : null;
        }
        return $rows;
    }
752911
public function createCommand($sql = null, $params = [])
    {
        $command = new Command([
            'db' => $this,
            'sql' => $sql,
        ]);

        return $command->bindValues($params);
    }
594619
public function command(string $sql, array $params = [])
    {
        return $this->execute($this->prepare($sql, $params));
    }
609085
public function getAllPosts($sql, $params)
    {
        $posts = $this->findAllWhere("$sql", $params);

        // array_reverse so latest order question gets returned
        return array_map(array($this, 'setupPost'), $posts);
    }
1118675
public function get_fieldset_sql($sql, array $params=null) {
        $rs = $this->get_recordset_sql($sql, $params);
        if (!$rs->valid()) {
            $rs->close(); // Not going to iterate (but exit), close rs
            return false;
        }
        $result = array();
        foreach($rs as $value) {
            $result[] = reset($value);
        }
        $rs->close();
        return $result;
    }
70505
public function getArray($sql = null, $parameters = array()) {
		$this->execute($sql);
		$result = array();
		while (!!$objs = mysqli_fetch_assoc($this->result) ) {
			$result[] = $objs;
		}
		return $result;
	}
383077
public function getResultsAsObjects($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetchAll(PDO::FETCH_OBJ);
    }
48339
public function query($sql, array $params = []) {
        $start_time = microtime(true);
        $this->sql  = $sql;
        $this->query->build()->reset();
        #准备sql
        $sth = $this->getLink(false)->prepare($sql);
        #设置保存数据
        $sth->setFetchMode(PDO::FETCH_ASSOC);
        #绑定参数
        $params = $this->setParamsSort($params);
        foreach ((array) $params as $key => $value) {
            $sth->bindParam($key, $params[$key], is_numeric($params[$key]) ? PDO::PARAM_INT : PDO::PARAM_STR);
        }
        try {
            #执行查询
            $sth->execute();
            $this->affectedRow = $sth->rowCount();
            $data              = $sth->fetchAll() ?: [];
            #记录日志
            if (DEBUG) {
                $end_time = microtime(true);

                self::$queryLog[] = array(
                    'sql'  => sql_processing($sql, $params),
                    'data' => to_json($data),
                    'time' => ($end_time - $start_time) . 'μs',
                );
            }
            return $data;
        } catch (Exception $e) {
            $error = $sth->errorInfo();
            throw new Exception($sql . " ;BindParams:" . var_export($params, true) . implode(';', $error));
        }
    }
343696
public function unionAllRaw(string $sql, string ...$params)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->unionAllRaw($sql, ...$params);

        return $instance;
    }
343621
public static function getSqlWithParams(string $sql, array $params = []): string
    {
        if (! empty($params)) {
            $indexed = ($params === array_values($params));
            foreach ($params as $k => $v) {
                if (is_string($v)) {
                    $v = "'${v}'";
                }
                if (is_array($v)) {
                    $v = "'" . implode("','", $v) . "'";
                }
                if ($indexed) {
                    $sql = preg_replace('/\?/', $v, $sql, 1);
                } else {
                    $sql = str_replace(":${k}", $v, $sql);
                }
            }
        }

        return str_replace(PHP_EOL, '', $sql);
    }
252129
public function query(string $sql, array $params = []): Statement
    {
        $this->usedPrepare = false;
        $stmt = $this->prepare($sql, $params);
        $this->usedPrepare = true;
        $stmt->execute();
        return $stmt;
    }
1171730
public function run($sql, array $params = array())
    {
        $sth = $this->pdo->prepare($sql);

        foreach ($params as $key => $value) {
            $key = is_numeric($key) ? $key + 1 : ":$key";
            $sth->bindValue($key, $value);
        }

        $sth->execute($params);
        $this->executed[] = $sql;
        return $sth;
    }
1047948
protected function emulate_bound_params($sql, array $params=null) {
        if (empty($params)) {
            return $sql;
        }
        // ok, we have verified sql statement with ? and correct number of params
        $parts = array_reverse(explode('?', $sql));
        $return = array_pop($parts);
        foreach ($params as $param) {
            if (is_bool($param)) {
                $return .= (int)$param;
            } else if (is_null($param)) {
                $return .= 'NULL';
            } else if (is_number($param)) {
                $return .= "'".$param."'"; // we have to always use strings because mysql is using weird automatic int casting
            } else if (is_float($param)) {
                $return .= $param;
            } else {
                $param = $this->mysqli->real_escape_string($param);
                $return .= "'$param'";
            }
            $return .= array_pop($parts);
        }
        return $return;
    }