Compile an Edge statement into SQL.

@param  \Illuminate\Database\Query\Builder $query
@param  array $values
@return string
439265
public function compileEdge(Builder $query, $parent, $related, $relationship = 'E', $values = [])
    {
        // Essentially we will force every insert to be treated as a batch insert which
        // simply makes creating the SQL easier for us since we can utilize the same
        // basic routine regardless of an amount of records given to us to insert.

        $from = $this->columnize([$parent->getAttributes()[$parent->getKeyName()]]);
        $to = $this->columnize([$related->getAttributes()[$related->getKeyName()]]);

//     code to check if relationship object exist or not
//        
//              if($relationship instanceof Relatio){
//            
//        }
        // Add content if there are the $values present
        $property_query = NULL;
        if ($values != NULL) {
            $property_query = "CONTENT " . json_encode($values);
        }
        return "create edge {$relationship->getType()} from $from to $to " . $property_query;

    }
125479
protected function compileUpdateJoinWheres(Builder $query)
    {
        $joinWheres = [];

        // Here we will just loop through all of the join constraints and compile them
        // all out then implode them. This should give us "where" like syntax after
        // everything has been built and then we will join it to the real wheres.
        foreach ($query->joins as $join) {
            foreach ($join->wheres as $where) {
                $method = "where{$where['type']}";

                $joinWheres[] = $where['boolean'] . ' ' . $this->{$method}($query, $where);
            }
        }

        return implode(' ', $joinWheres);
    }
161385
public function query(DataStructure\Query\Query $queries)
    {
        $logicFunc = 'andWhere';
        if ($queries instanceof DataStructure\OrQuery) {
            $logicFunc = 'orWhere';
        }

        foreach ($queries as $query) {

            if ($this->isExcludedProperty($query->getProperty())) {
                continue;
            }

            $value = $this->unlockSpecialProperty($query->getProperty(), $query->getValue());

            if ($query instanceof Expression\Equal) {

                $this->criteria->{$logicFunc}(Criteria::expr()->eq($query->getProperty(), $value));

            } elseif ($query instanceof Expression\NotEqual) {

                $this->criteria->{$logicFunc}(Criteria::expr()->neq($query->getProperty(), $value));

            } elseif ($query instanceof Expression\GreaterThan) {

                $this->criteria->{$logicFunc}(Criteria::expr()->gt($query->getProperty(), $value));

            } elseif ($query instanceof Expression\GreaterThanEqual) {

                $this->criteria->{$logicFunc}(Criteria::expr()->gte($query->getProperty(), $value));

            } elseif ($query instanceof Expression\LesserThan) {

                $this->criteria->{$logicFunc}(Criteria::expr()->lt($query->getProperty(), $value));

            } elseif ($query instanceof Expression\LesserThanEqual) {

                $this->criteria->{$logicFunc}(Criteria::expr()->lte($query->getProperty(), $value));

            } elseif ($query instanceof Expression\In) {

                $this->criteria->{$logicFunc}(Criteria::expr()->in($query->getProperty(), $value));

            } elseif ($query instanceof Expression\NotIn) {

                $this->criteria->{$logicFunc}(Criteria::expr()->notIn($query->getProperty(), $query->getValue()));

            }

        }
    }
887426
public function compileUpdate(Builder $query, $values) {
    $this->beforePut($values);
    $this->remapWheres($query);
    return $this->grammar->compileUpdate($query, $values);
  }
74673
protected function whereRowValues(Builder $query, $where)
    {
        $columns = $this->columnize($where['columns']);

        $values = $this->parameterize($where['values']);

        return '('.$columns.') '.$where['operator'].' ('.$values.')';
    }
364874
public function compileDelete(Builder $query)
    {
        // keyspace-ref:
        $table = $this->wrapTable($query->from);
        // use-keys-clause:
        $keyClause = null;
        if ($query->key) {
            $key = $this->wrapKey($query->key);
            $keyClause = "USE KEYS {$key}";
        }
        // returning-clause
        $returning = implode(', ', $query->returning);
        $where = is_array($query->wheres) ? $this->compileWheres($query) : '';

        return trim("delete from {$table} {$keyClause} {$where} RETURNING {$returning}");
    }
202766
public function values(array $values) : QueryBuilder
    {
        $args    = func_get_args();
        $columns = [];
        $_values = [];

        foreach($values as $key => $value) {
            preg_match("/\(JSON\)\s*([\w]+)/i", $key, $jsonTag);

            if(
                is_array($value) ||
                is_object($value)
            ) {
                if(isset($jsonTag[0])) {
                    $key       = preg_replace('/\(JSON\)\s*([\w]+)/i', '$1', $key);
                    $_values[] = $this->getQuoted(json_encode($value));
                } else {
                    $_values[] = $this->getQuoted(serialize($value));
                }
            } else if(is_bool($value)) {
                $_values[] = ($value ? 1 : 0);
            } else if(is_null($value)) {
                $_values[] = "NULL";
            } else {
                $_values[] = $this->getQuoted($value);
            }

            $columns[] = "`". $this->sanitize($key) ."`";
        }

        $this->_query[] = "(". implode(", ", $columns) .")";
        $this->_query[] = "VALUES";
        $this->_query[] = "(". implode(", ", $_values) .")";

        return $this;
    }
1225363
protected function compileUpdateFrom(Builder $query)
	{
		if ( ! isset($query->joins)) return '';

		$froms = array();

		// When using Postgres, updates with joins list the joined tables in the from
		// clause, which is different than other systems like MySQL. Here, we will
		// compile out the tables that are joined and add them to a from clause.
		foreach ($query->joins as $join)
		{
			$froms[] = $this->wrapTable($join->table);
		}

		if (count($froms) > 0) return ' from '.implode(', ', $froms);
	}
318290
public function compileInsert(Builder $query, array $values)
	{
		// Essentially we will force every insert to be treated as a batch insert which
		// simply makes creating the SQL easier for us since we can utilize the same
		// basic routine regardless of an amount of records given to us to insert.
		$table = $this->wrapTable($query->from);

		if ( ! is_array(reset($values)))
		{
			$values = array($values);
		}

		$columns = $this->columnize(array_keys(reset($values)));

		// We need to build a list of parameter place-holders of values that are bound
		// to the query. Each insert should have the exact same amount of parameter
		// bindings so we can just go off the first list of values in this array.
		$parameters = $this->parameterize(reset($values));

		$value = array_fill(0, count($values), "($parameters)");

		$parameters = implode(', ', $value);

		return "insert into $table ($columns) values $parameters";
	}
93042
protected function compileOffsetAndLimitPart(Query $query, array &$bindings): string
    {
        $parts = [];

        if ($query->limit !== null) {
            $parts[] = 'LIMIT '.$this->compileValue($query->limit, $bindings);

            if ($query->offset !== null) {
                $parts[] = 'OFFSET '.$this->compileValue($query->offset, $bindings);
            }
        } else {
            if ($query->offset !== null) {
                throw new InvalidQueryException('Offset is not allowed without Limit');
            }
        }

        return $this->implodeSQL($parts);
    }
1116464
public function compileUpdate(Builder $query, $values)
	{
		$table = $this->wrapTable($query->from);

		$columns = [];

		// Each one of the columns in the update statements needs to be wrapped in the
		// keyword identifiers, also a place-holder needs to be created for each of
		// the values in the list of bindings so we can make the sets statements.
		foreach ($values as $key => $value) {
			if ($this->isJsonSelector($key)) {
				$columns[] = $this->compileJsonUpdateColumn(
					$key, new JsonExpression($value)
				);
			} else {
				$columns[] = $this->wrap($key).' = '.$this->parameter($value);
			}
		}

		$columns = implode(', ', $columns);

		// If the query has any "join" clauses, we will setup the joins on the builder
		// and compile them so we can attach them to this update, as update queries
		// can get join statements to attach to other tables when they're needed.
		if (isset($query->joins)) {
			$joins = ' '.$this->compileJoins($query, $query->joins);
		} else {
			$joins = '';
		}

		// Of course, update queries may also be constrained by where clauses so we'll
		// need to compile the where clauses and attach it to the query so only the
		// intended records are updated by the SQL statements we generate to run.
		$where = $this->compileWheres($query);

		$sql = rtrim("update {$table}{$joins} set $columns $where");

		if (isset($query->orders)) {
			$sql .= ' '.$this->compileOrders($query, $query->orders);
		}

		if (isset($query->limit)) {
			$sql .= ' '.$this->compileLimit($query, $query->limit);
		}

		return rtrim($sql);
	}
393944
protected function compileJoins(Builder $query, $joins)
    {
        return collect($joins)->map(function ($join) use ($query) {
            $table = $this->wrapTable($join->table);

            $nestedJoins = is_null($join->joins) ? '' : ' '.$this->compileJoins($query, $join->joins);

            $tableAndNestedJoins = is_null($join->joins) ? $table : '('.$table.$nestedJoins.')';

            return trim("{$join->type} join {$tableAndNestedJoins} {$this->compileWheres($join)}");
        })->implode(' ');
    }
850832
public function compileUpdateLob(Builder $query, array $values, array $binaries, $sequence = 'id')
    {
        $table = $this->wrapTable($query->from);

        // Each one of the columns in the update statements needs to be wrapped in the
        // keyword identifiers, also a place-holder needs to be created for each of
        // the values in the list of bindings so we can make the sets statements.
        $columns = [];

        foreach ($values as $key => $value) {
            $columns[] = $this->wrap($key) . ' = ' . $this->parameter($value);
        }

        $columns = implode(', ', $columns);

        // set blob variables
        if (! is_array(reset($binaries))) {
            $binaries = [$binaries];
        }
        $binaryColumns    = $this->columnize(array_keys(reset($binaries)));
        $binaryParameters = $this->parameterize(reset($binaries));

        // create EMPTY_BLOB sql for each binary
        $binarySql = [];
        foreach ((array) $binaryColumns as $binary) {
            $binarySql[] = "$binary = EMPTY_BLOB()";
        }

        // prepare binary SQLs
        if (count($binarySql)) {
            $binarySql = (empty($columns) ? '' : ', ') . implode(',', $binarySql);
        }

        // If the query has any "join" clauses, we will setup the joins on the builder
        // and compile them so we can attach them to this update, as update queries
        // can get join statements to attach to other tables when they're needed.
        $joins = '';
        if (isset($query->joins)) {
            $joins = ' ' . $this->compileJoins($query, $query->joins);
        }

        // Of course, update queries may also be constrained by where clauses so we'll
        // need to compile the where clauses and attach it to the query so only the
        // intended records are updated by the SQL statements we generate to run.
        $where = $this->compileWheres($query);

        return "update {$table}{$joins} set $columns$binarySql $where returning " . $binaryColumns . ', ' . $this->wrap($sequence) . ' into ' . $binaryParameters . ', ?';
    }
715599
private function executeQueryIn(QueryBuilder $query, $field, array $values)
    {
        array_walk(
                $values,
                function(&$value, $key, $query) {
                    $value = $query->expr()->literal($value);
                },
                $query
        );

        return $query->where($query->expr()->in($field, $values))
                        ->execute()
                        ->fetchAll(\PDO::FETCH_COLUMN);
    }
615734
protected function compileQuery()
    {
        $query = $this->sql;

        // Auto-generate the SET/VALUES subpart
        if (strncasecmp($query, 'INSERT', 6) === 0 || strncasecmp($query, 'UPDATE', 6) === 0) {
            $query = str_replace('%s', '%p', $query);
        }

        // Replace wildcards
        $chunks = preg_split("/('[^']*')/", $query, -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));

        foreach ($chunks as $k => $v) {
            if (substr($v, 0, 1) == "'") {
                continue;
            }

            $chunks[$k] = str_replace('?', '%s', $v);
        }

        $query = implode('', $chunks);


        $query = preg_replace('/(?<!%)%([^bcdufosxX%])/', '%%$1', $query);

        // Replace wildcards
        // @codingStandardsIgnoreStart
        if (($this->compiledQuery = @vsprintf($query, $this->escapeParameters())) == false) {
        // @codingStandardsIgnoreEnd
            throw new \Exception('Too few arguments to build the query string');
        }
    }
889306
protected function compileJoinPart(Query $query, array &$bindings): string
    {
        $joinsSQL = [];

        foreach ($query->join as $join) {
            $joinsSQL[] = $this->compileOneJoin($join, $bindings);
        }

        return $this->implodeSQL($joinsSQL);
    }
173241
public function compileInsert(Builder $query, array $values)
	{
		// Essentially we will force every insert to be treated as a batch insert which
		// simply makes creating the SQL easier for us since we can utilize the same
		// basic routine regardless of an amount of records given to us to insert.
		$table = $this->wrapTable($query->from);

		if ( ! is_array(reset($values)))
		{
			$values = array($values);
		}

		// If there is only one record being inserted, we will just use the usual query
		// grammar insert builder because no special syntax is needed for the single
		// row inserts in SQLite. However, if there are multiples, we'll continue.
		if (count($values) == 1)
		{
			return parent::compileInsert($query, reset($values));
		}

		$names = $this->columnize(array_keys(reset($values)));

		$columns = array();

		// SQLite requires us to build the multi-row insert as a listing of select with
		// unions joining them together. So we'll build out this list of columns and
		// then join them all together with select unions to complete the queries.
		foreach (array_keys(reset($values)) as $column)
		{
			$columns[] = '? as '.$this->wrap($column);
		}

		$columns = array_fill(0, count($values), implode(', ', $columns));

		return "insert into $table ($names) select ".implode(' union select ', $columns);
	}