本文整理汇总了PHP中Cake\ORM\Query::defaultTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::defaultTypes方法的具体用法?PHP Query::defaultTypes怎么用?PHP Query::defaultTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Query
的用法示例。
在下文中一共展示了Query::defaultTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createTupleCondition
/**
* Returns a TupleComparison object that can be used for matching all the fields
* from $keys with the tuple values in $filter using the provided operator.
*
* @param \Cake\ORM\Query $query Target table's query
* @param array $keys the fields that should be used for filtering
* @param mixed $filter the value that should be used to match for $key
* @param string $operator The operator for comparing the tuples
* @return \Cake\Database\Expression\TupleComparison
*/
protected function _createTupleCondition($query, $keys, $filter, $operator)
{
$types = [];
$defaults = $query->defaultTypes();
foreach ($keys as $k) {
if (isset($defaults[$k])) {
$types[] = $defaults[$k];
}
}
return new TupleComparison($keys, $filter, $types, $operator);
}
示例2: _addFilteringCondition
/**
* Appends any conditions required to load the relevant set of records in the
* target table query given a filter key and some filtering values.
*
* @param \Cake\ORM\Query $query Target table's query
* @param string $key the fields that should be used for filtering
* @param mixed $filter the value that should be used to match for $key
* @return \Cake\ORM\Query
*/
protected function _addFilteringCondition($query, $key, $filter)
{
if (is_array($key)) {
$types = [];
$defaults = $query->defaultTypes();
foreach ($key as $k) {
if (isset($defaults[$k])) {
$types[] = $defaults[$k];
}
}
return $query->andWhere(new TupleComparison($key, $filter, $types, 'IN'));
}
return $query->andWhere([$key . ' IN' => $filter]);
}