fetch a direct query

@param $sql
@param $param array of bind parameters

@return $this
427781
public function query($sql, $param = null)
    {
        $this->__init_database();
        // direct wrapper for fetch
        $stmt = $this->db->prepare($sql);

        for ($i = 0, $c = count($param); $i < $c; $i++) {
            $stmt->bindParam($param[$i][0], $param[$i][1]);
        }

        $this->last_sql = $sql;
        if (!$stmt->execute()) return $this;

        $this->result = $stmt->fetchAll(MySQL::FETCH_OBJ);

        return $this;
    }
325884
public function orderBy($sql, $params=array())
    {
        $binder = new Binder();
        $this->_order = array($binder->magicBind($sql, (array) $params));

        return $this;
    }
152773
public function query($query,$sqlParams=null)
    {
        $this->query =  (string)$query;
        if ($sqlParams!=null) {
            $this->sqlParams = $sqlParams;
        }
        return $this;
    }
368018
public function getRow($sql, $params = array())
    {
        $stmt = $this->execute($sql, $params);
        return $stmt->fetch($this->fetchMode);
    }
1329388
public function fetchAll($sql, $params = array(), $types = array())
    {
        return $this->query($sql, $params, $types)->fetchAll();
    }
686658
public function sqlFetchColumn(string $sql, array $params = [], string $column = '0')
    {
        return $this->connection()->sqlFetchColumn($sql, $params, $column);
    }
1037890
public function query($sql, array $params = [], $target = Database::TARGET_MASTER)
    {
        $con = $this->establishConnection($target);
        $sth = $con->prepare($sql);

        // bind params
        foreach($params as $key => $value){
            $type = Connection::PARAM_STR;
            if (is_null($value)) {
                $type = Connection::PARAM_NULL;
            } elseif (is_int($value)) {
                $type = Connection::PARAM_INT;
            } elseif (is_bool($value)) {
                $type = Connection::PARAM_BOOL;
            } elseif (is_resource($value)) {
                $type = Connection::PARAM_LOB;
            }
            $sth->bindValue($key, $value, $type);
        }

        try {

            $e = null;
            $start = microtime(true);
            $result = $sth->execute();

        } catch (PDOException $e) {
            // deadlock
            if ($e->getCode() == '40001') {
                $e = new DeadlockException(sprintf('%s (%s)', $e->getMessage(), $sql), (int)$e->getCode(), $e);
            } else {
                $e = new PDOException(sprintf('%s (%s)', $e->getMessage(), $sql), (int)$e->getCode(), $e);
            }
        }

        $end = microtime(true);
        $this->console->log(sprintf('[%01.4f] %s', $end - $start, $sql));
        $this->console->log($params);

        if ($e) {
            $this->console->fatal(sprintf('[%s] %s', $e->getCode(), $e->getMessage()));
            $this->console->fatal($params);
            throw $e;
        }

        return $sth;
    }
849242
public static function fetchSQL(string $sql, array $params, string $compileDir)
    {
        $sdopx = new Sdopx();
        $sdopx->setCompileDir($compileDir);
        $sdopx->assign($params);
        $sdopx->parsingType = Sdopx::PARSING_SQL;
        return $sdopx->fetch('string:' . $sql);
    }
1304266
public function fetchAll($sql, array $params = [], $types = [])
    {
        return $this->executeQuery($sql, $params, $types)->fetchAll();
    }
1196314
public function fetchOne($sql, $bind = array())
    {
        $stmt = $this->query($sql, $bind);
        $result = $stmt->fetchColumn(0);
        return $result;
    }
1364737
function sql($sql = null, $params = NULL) {
        $params = $this->autoarr($params);
        $sql = str_replace('table.',$this->alias.'.',$sql);
        return $this->execute($sql, $params);
        return $this;
    }
1148219
public function fetchArrayPDO($sql, array $params = array())
    {

        $query_id = $this->_queryPDO($sql, $params);
        if ($query_id === false) {
            return false;
        }
        $out = array();

        while ($row = $this->_fetchPDO()) {
            $out[] = $row;
        }

        $this->_freeResultPDO();
        return $out;
    }
925762
public function fetchColumn($sql, array $params = array(), $pos = 0)
    {
        return $this->run($sql, $params)->fetchColumn($pos);
    }
869927
public function getResults($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }
252981
public function createCommand($sql = null, $params = [])
    {
        /** @var Command $command */
        $command = new $this->commandClass([
            'db' => $this,
            'sql' => $sql,
        ]);

        return $command->bindValues($params);
    }
1054226
public static function query($sql,$bind=[])
    {
        try{
            $bind=is_array($bind) ? $bind : [$bind];
            self::$db=Connect::boot();
            Connect::comSql($sql);
            $sth = self::$db->prepare($sql);
            $sth->execute($bind);
            $sth->setFetchMode(\PDO::FETCH_ASSOC);

            return $sth;
        } catch (\PDOException $e) {
            throw new Exception($e->getMessage());
            //View::throwError($error);
        }
    }
524596
public function whereRaw(string $sql, string ...$params)
    {
        $instance = $this->whereStrategyInstance();

        $instance->whereStrategy()->whereRaw($sql, ...$params);

        return $instance;
    }