@param string $sql
@param array  $bindings

@return BaseQueryRelateContract
973213
public function orderByRaw(string $sql, array $bindings = []): BaseQueryRelateContract
    {
        $this->query->orderByRaw($sql, $bindings);

        return $this;
    }
153721
public function prepare(string $statement, array $bindings = []): RawQueryBuilder
    {
        $this->statement = $statement;
        $this->bindings = $bindings;

        return $this;
    }
1080740
public function bind($sql, array $params=array())
    {
        return $this->_bindInto('\?', $sql, $params, function($binder, $param) use ($sql) {
            return $binder->sqlValue($param);
        });
    }
536086
protected function checkBindings(string $query, array $bindings)
    {
        $bindingsCountInQuery = $this->countBindingsFromQuery($query);
        $bindingsCount = count($bindings);

        if ($bindingsCountInQuery !== $bindingsCount) {
            throw QueryMapperException::wrongBindingsNumber($bindingsCountInQuery, $bindingsCount);
        }

        $this->checkBindingsPolicy($bindings);
    }
1168586
public function orHaving($column, $operator = null, $value = null): BaseQueryRelateContract
    {
        $this->query->orHaving($column, $operator, $value);

        return $this;
    }
13119
public function query(string $sql, $bind = []): Result
    {
        $result = parent::query($sql, $bind);
        return new Result($this->tableName, $result);
    }
582271
public function whereRaw($sql, $bindings = [], $boolean = 'and')
    {
        $this->wheres[] = ['type' => 'raw', 'sql' => $sql, 'boolean' => $boolean];

        $this->addBinding((array) $bindings, 'where');

        return $this;
    }
915575
public function exec($sql = "", $bindingValues = array(), $insert = true)
    {
        //Check if the query is a SELECT|INSERT|UPDATE and :variation is available
        if (preg_match("/.*(SELECT|INSERT|UPDATE|SHOW|DELETE).*/", $sql)) {
            
            $this->sql = $sql;

            //Always prepare the SQL statement first
            $query = $this->connection->prepare($sql);

            if (preg_match('/\s*:(.+?)\s/', $sql)) {
                if (is_array($bindingValues) && !empty($bindingValues)) {
                    foreach ($bindingValues as $key => $val) {
                        //Clean the bindingValues. Check if they start with :
                        if (!preg_match('/:.*/', $key)) {
                            $bindingValues[":" . $key] = $val;
                            unset($bindingValues[$key]);
                        }
                    }
                }


                //Add the binding variables to the query
                if ($query->execute($bindingValues)) {
                    return $this->getLastInsertID();
                } else {
                    //@ToDo:When the save or update fails make sure we handle the error gracefully!
                    throw new \Exception(implode("\n", $query->errorInfo()));
                }

            } else {
                $result = $query->execute();
            }

            if (preg_match('/.*(SELECT|SHOW).*/', $sql)) {
                $query->setFetchMode(\PDO::FETCH_ASSOC);
                return $query->fetchAll();
            }

            return $result;
        }


        return false;
    }
860289
public static function findOne($sql = null, $bindings = [])
    {
        $bean = DB::findOne(static::getTable(), $sql, $bindings);
        return static::wrap($bean);
    }
239648
public function statement($sql, $bindings = array())
		{
			list($statement, $result) = $this->execute($sql, $bindings);
			return $result;
		}
742641
public function selectFromWriteConnection( $query, $bindings = [ ], $resultClass = null )
	{
		return $this->select( $query, $bindings, false, $resultClass );
	}
763492
public function bind($bindings, $type = [])
	{
		$idx = 1;

		$this->bindings = $bindings;

		foreach ($bindings as $binding)
		{
			// We use bindValue here because that allows us to pass in plain old strings
			$this->statement->bindValue(
				$idx,
				$binding,
				isset($type[$idx]) ? $this->translateType($type[$idx]) : $this->inferType($binding)
			);

			$idx++;
		}

		return $this;
	}
766146
protected function statement($query, $bindings = array())
    {
        $statement  = $this->getActivePdo()->prepare($query);

        return $statement->execute($bindings);
    }
1122602
public function query(string $sql, array $bindings = []): IQueryBuilderHandler
    {
        $queryObject = new QueryObject($sql, $bindings, $this->getConnection());
        $this->connection->setLastQuery($queryObject);

        $this->fireEvents(EventHandler::EVENT_BEFORE_QUERY, $queryObject);

        [$response, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());

        $this->fireEvents(EventHandler::EVENT_AFTER_QUERY, $queryObject, [
            'execution_time' => $executionTime,
        ]);

        $this->pdoStatement = $response;

        return $this;
    }
369022
protected function formatMessage( $sql, $bindings, $previous ) {
		foreach ( $bindings as $value ) {
			$sql = preg_replace( '/\?/', $value, $sql, 1 );
		}

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

        return $this;
    }
355332
public function select($query, $bindings = array()) {
        return $this->run($query, $bindings, function(self $me, $query, array $bindings) {
                    if ($me->pretending())
                        return array();
                    // For select statements, we'll simply execute the query and return an array
                    // of the database result set. Each element in the array will be a single
                    // node from the database, and will either be an array or objects.
                     $statement = $me->getBatchQuery($query, $bindings);
                    return $statement->getResultSet();
                    
                    // $statement = $me->getCypherQuery($query, $bindings);
                    // return $statement->getResultSet();

                });
    }