本文整理汇总了PHP中Illuminate\Database\Query\Builder::modelAsNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::modelAsNode方法的具体用法?PHP Builder::modelAsNode怎么用?PHP Builder::modelAsNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::modelAsNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compileFrom
/**
* Compile the "from" portion of the query
* which in cypher represents the nodes we're MATCHing
*
* @param \Vinelab\NeoEloquent\Query\Builder $query
* @param string $labels
* @return string
*/
public function compileFrom(Builder $query, $labels)
{
// Only compile when no relational matches are specified,
// mostly used for simple queries.
if (!empty($query->matches)) {
return '';
}
// first we will check whether we need
// to reformat the labels from an array
if (is_array($labels)) {
$labels = $this->prepareLabels($labels);
}
// every label must begin with a ':' so we need to check
// and reformat if need be.
$labels = ':' . preg_replace('/^:/', '', $labels);
// now we add the default placeholder for this node
$labels = $query->modelAsNode() . $labels;
return sprintf("MATCH (%s)", $labels);
}
示例2: compileUpdateLabels
/**
* Compile an statement to add or drop node labels
*
* @param \Vinelab\NeoEloquent\Query\Builder $query
* @param array $labels labels as string like :label1:label2 etc
* @param array $operation type of operation 'add' or 'drop'
* @return string
*/
public function compileUpdateLabels(Builder $query, $labels, $operation = 'add')
{
if (trim(strtolower($operation)) == 'add') {
$updateType = 'SET';
} else {
$updateType = 'REMOVE';
}
// 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.
$labels = $query->modelAsNode() . $this->prepareLabels($labels);
// 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 Cypher statements we generate to run.
$where = $this->compileWheres($query);
// We always need the MATCH clause in our Cypher which
// is the responsibility of compiling the From component.
$match = $this->compileComponents($query, array('from'));
$match = $match['from'];
return "{$match} {$where} {$updateType} {$labels} ";
}