本文整理汇总了PHP中Cake\Database\Query::traverse方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::traverse方法的具体用法?PHP Query::traverse怎么用?PHP Query::traverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Database\Query
的用法示例。
在下文中一共展示了Query::traverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Returns the SQL representation of the provided query after generating
* the placeholders for the bound values using the provided generator
*
* @param \Cake\Database\Query $query The query that is being compiled
* @param \Cake\Database\ValueBinder $generator the placeholder generator to be used in expressions
* @return \Closure
*/
public function compile(Query $query, ValueBinder $generator)
{
$sql = '';
$type = $query->type();
$query->traverse($this->_sqlCompiler($sql, $query, $generator), $this->{'_' . $type . 'Parts'});
return $sql;
}
示例2: compile
/**
* Returns the SQL representation of the provided query after generating
* the placeholders for the bound values using the provided generator
*
* @param \Cake\Database\Query $query The query that is being compiled
* @param \Cake\Database\ValueBinder $generator the placeholder generator to be used in expressions
* @return \Closure
*/
public function compile(Query $query, ValueBinder $generator)
{
$sql = '';
$type = $query->type();
$query->traverse($this->_sqlCompiler($sql, $query, $generator), $this->{'_' . $type . 'Parts'});
// Propagate bound parameters from sub-queries if the
// placeholders can be found in the SQL statement.
if ($query->valueBinder() !== $generator) {
foreach ($query->valueBinder()->bindings() as $binding) {
$placeholder = ':' . $binding['placeholder'];
if (preg_match('/' . $placeholder . '(?:\\W|$)/', $sql) > 0) {
$generator->bind($placeholder, $binding['value'], $binding['type']);
}
}
}
return $sql;
}