{@inheritdoc}

@param array                            $binding (optional)
@param bool                             $returnAffected (optional)

@return \Ems\Contracts\Expression\Prepared
548897
public function prepare($query, array $bindings=[])
    {
        $statement = $this->statement($query);

        $this->callBeforeListeners('prepare',[$query, $bindings]);

        $prepared = (new PDOPrepared(
            $statement,
            $query,
            $this->getOption(self::RETURN_LAST_AFFECTED),
            $this->errorHandler
        ))->bind($bindings);

        $this->callAfterListeners('prepare',[$query, $bindings, $prepared]);

        return $prepared;

    }
1190537
public function prepareBindingsForUpdate(array $bindings, array $values)
	{
		$values = (new Collection($values))->reject(function ($value, $column) {
			return $this->isJsonSelector($column) &&
			in_array(gettype($value), ['boolean', 'integer', 'double']);
		})->getAll();

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

        return $this;
    }
131649
public function prepare($bindings= array (), $byValue= true, $cacheFlag= null) {
        $this->stmt= null;
        if ($this->construct() && $this->stmt= $this->xpdo->prepare($this->sql)) {
            $this->bind($bindings, $byValue, $cacheFlag);
        } else {
            $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not construct or prepare query because it is invalid or could not connect: ' . $this->sql);
        }
        return $this->stmt;
    }
472920
public function render(ExpressionContract $expression, array &$bindings=[])
    {

        if ($expression instanceof KeyExpression) {
            return $this->renderKeyExpression($expression);
        }

        if ($expression instanceof Constraint) {
            return $this->renderConstraint($expression, $bindings);
        }

        if ($expression instanceof Condition) {
            return $this->renderCondition($expression, $bindings);
        }

        if (!$expression instanceof LogicalGroup) {
            throw new InvalidArgumentException("Cannot render a " . Type::of($expression));
        }

        $parts = [];

        foreach ($expression->expressions() as $e) {

            if ($e instanceof LogicalGroup) {
                $parts[] = "(" . $this->render($e, $bindings) . ')';
                continue;
            }

            $parts[] = $this->render($e, $bindings);
        }

        return implode(' ' . strtoupper($expression->operator()) . ' ', $parts);
    }
854553
public function query($sql, $bind = array())
    {
        $this->prepare($sql, $bind);

        return $this->db->query($sql, $bind);
    }
1220119
public function fromRaw($expression, $bindings = [])
    {
        $this->from = new Expression($expression);

        $this->addBinding($bindings, 'from');

        return $this;
    }
377290
public function prepareBindingsForUpdate(array $bindings, array $values)
    {
        $values = collect($values)->reject(function ($value, $column) {
            return $this->isJsonSelector($column) && is_bool($value);
        })->all();

        return parent::prepareBindingsForUpdate($bindings, $values);
    }
434027
public function createStatementFromProcedure($procedureName, array $bindings, $cursorName = false)
    {
        $sql = $this->createSqlFromProcedure($procedureName, $bindings, $cursorName);

        return $this->getPdo()->prepare($sql);
    }
500872
public function select( $query, $bindings = [] )
	{
		$query = $this->bind_params( $query, $bindings );

		$result = $this->db->get_results( $query );

		if ( $result === false || $this->db->last_error ) {
			throw new QueryException( $query, $bindings, new \Exception( $this->db->last_error ) );
		}

		return $result;
	}
1141430
protected function compileBinding(Binding $binding)
	{
		$prop = str_replace('\\', '_', $binding->getTypeName());
			
		$code = "\tpublic function binding_" . $prop . "() {\n\n";
		
		$code .= "\t\t\t\$binding = new DelegateBinding(" . var_export($binding->getTypeName(), true);
		$code .= ', ' . var_export($binding->getScope(), true);
		$code .= ', ' . var_export($binding->getOptions(), true) . ', function(InjectionPointInterface $point = NULL) {' . "\n";
		
		switch($binding->getOptions() & BindingInterface::MASK_TYPE)
		{
			case BindingInterface::TYPE_ALIAS:
				$code .= "return \$this->get(" . var_export($binding->getTarget(), true) . ", \$point);\n";
				break;
			case BindingInterface::TYPE_IMPLEMENTATION:
				$code .= $this->compileImplementationBinding($binding);
				break;
			case BindingInterface::TYPE_FACTORY_ALIAS:
				$code .= $this->compileFactoryBinding($binding);
				break;
			case BindingInterface::TYPE_FACTORY:
				$code .= $this->compileInlineFactoryBinding($binding);
		}
		
		$code .= "});\n";
		$code .= "\t\treturn \$binding;\n";
		$code .= "\t}\n\n";
		
		return $code;
	}
309017
public function whereExpr($expr, $bind = null)
    {
        foreach ($this->queries as $query) {
            $query->whereExpr($expr, $bind);
        }

        return $this;
    }
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;
    }
625720
public function prepareBindingsForUpdate(array $bindings, array $values)
    {
        $values = collect($values)->map(function ($value, $column) {
            return $this->isJsonSelector($column) && ! $this->isExpression($value)
                ? json_encode($value)
                : $value;
        })->all();

        // Update statements with "joins" in Postgres use an interesting syntax. We need to
        // take all of the bindings and put them on the end of this array since they are
        // added to the end of the "where" clause statements as typical where clauses.
        $bindingsWithoutJoin = Arr::except($bindings, 'join');

        return array_values(
            array_merge($values, $bindings['join'], Arr::flatten($bindingsWithoutJoin))
        );
    }
734039
public function escapeBindings($bindings)
    {
        foreach ($bindings as &$binding) {
            $binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
        }

        return $bindings;
    }
323416
public function prepareBindings(array $bindings)
    {
        $grammar = $this->getQueryGrammar();

        $prepared = array();

        foreach ($bindings as $key => $binding)
        {
            // The bindings are collected in a little bit different way than
            // Eloquent, we will need the key name in order to know where to replace
            // the value using the Neo4j client.
            $value = $binding;

            // We need to get the array value of the binding
            // if it were mapped
            if (is_array($value))
            {
                // There are different ways to handle multiple
                // bindings vs. single bindings as values.
                $value = array_values($value);
            }

            // We need to transform all instances of the DateTime class into an actual
            // date string. Each query grammar maintains its own date string format
            // so we'll just ask the grammar for the format to get from the date.

            if ($value instanceof DateTime)
            {
                $binding = $value->format($grammar->getDateFormat());
            }

            $property = is_array($binding) ? key($binding) : $key;

            // We will set the binding key and value, then
            // we replace the binding property of the id (if found)
            // with a _nodeId instead since the client
            // will not accept replacing "id(n)" with a value
            // which have been previously processed by the grammar
            // to be _nodeId instead.
            if ( ! is_array($binding))
            {
                $binding = [$binding];
            }

            foreach ($binding as $property => $real)
            {
                // We should not pass any numeric key-value items since the Neo4j client expects
                // a JSON map parameters.
                if (is_numeric($property))
                {
                    $property = (! is_numeric($key)) ? $key : 'id';
                }

                if ($property == 'id') $property = $grammar->getIdReplacement($property);

                $prepared[$property] = $real;
            }
        }

        return $prepared;
    }
110578
public function getBindings($binding = null)
    {
        if (is_null($binding)) {
            return $this->bindings;
        }

        return $this->bindings[$binding];
    }