@param null $sql

@return ORM|null
486199
public function first($sql = null)
    {
        $obj = $this->getFirst($sql);

        if ($obj && $this->getWith()) {
            $collection = new Collection();
            $collection->add($obj);

            $this->resolveRelations($collection);

            return $collection->first();
        }

        return $obj;
    }
1273079
public function execute($sql, $params = null)
    {
        $stmt = $this->_pdo->prepare($sql);

        if (is_array($params)) {
            foreach ($params as $token => $value) {
                $stmt->bindValue($token, $value);
            }
        }

        try {
            $stmt->execute();
        } catch (PDOException $exception) {
            $this->_database->error('execute', $exception);
        }

        return $stmt;
    }
44267
public function queryValue(string $sql, string $column, $default = null)
    {
        $result = $default;
        if ($row = $this->query($sql)->fetch(PDO::FETCH_ASSOC)) {
            $result = $row[$column];
        }

        return $result;
    }
201589
public function query($sql, $key = null, $options = []) {
		return $this->object->query($sql, $key, $options);
	}
1181705
public function execute($sql) {
        try {
            $lastExecMode = $this->skipResults;
            $this->skipResults = true;

            $this->executeRaw($sql);
            return $this;
        }
        finally {
            $this->skipResults = $lastExecMode;
        }
    }
1016182
public function query($sql) {
        $result = $this->executeRaw($sql);
        if (!is_resource($result))
            $result = null;
        return new MySQLResult($this, $sql, $result, $this->lastInsertId(), $this->lastAffectedRows());
    }
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;
    }
535366
public function raw($sql)
    {
        $query = new Query\SqlQuery();

        if ($this->pdo) {
            $query->setPDO($this->pdo);
        }

        return $query->raw($sql);
    }
1155792
public function getValue($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetchColumn(0);
    }
974069
public function getFirst($sql = null)
    {
        $result = $this->builder->getFirst($sql);

        if (isset($result[0])) {
            return self::instance($result[0]);
        }

        return null;
    }
476989
public function orWhere($sql=null, $params=array())
    {
        if(!isset($this->_where))
            $this->_where = new Criteria();

        $this->_where->or(new Criteria($sql, $params));

        return $this;
    }
524596
public function whereRaw(string $sql, string ...$params)
    {
        $instance = $this->whereStrategyInstance();

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

        return $instance;
    }
1095023
protected function query_row ( $sql )
	{
		list($sql, $args) = $this->sql_args(func_get_args());
		return any_db_query_row($sql, $args);
	}
265594
public function query(string $sql)
    {
        $generator = $this->__query($sql);
        if(!$generator->valid())
        {
            return $generator->getReturn();
        }
        $current = $generator->current();
        $generator->next();
        $generator->send($current);
        return $generator->getReturn();
    }
1204547
public function getRow($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetch(PDO::FETCH_ASSOC);
    }
224242
public function fetch_objects($sql)
    {
        $result = $this->query($sql);
        $array  = null;
        while (true == ($row = mysql_fetch_object($result))) {
            $array[] = $row;
        }
        mysql_free_result($result);
        return $array;
    }
1320280
public function parse_sql( $data = null ) {

		if ( ! empty( $data ) ) {
			$this->input = $data;
		}

		$this->parsed = $data;

		return $this->parsed;
	}