本文整理汇总了PHP中SQLQuery::useDisjunction方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::useDisjunction方法的具体用法?PHP SQLQuery::useDisjunction怎么用?PHP SQLQuery::useDisjunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::useDisjunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSuggestions
private function getSuggestions($req)
{
$request = Convert::raw2sql($req->requestVar('request'));
// If the class to pick config value is not set, this will not work too well!
// In that case, we'll just return an empty result.
if (empty($this->config['classToPick'])) {
$results = array(array('id' => '0', 'title' => 'none selected', 'full' => "select none", 'style' => 'color:red'));
} else {
$class = $this->config['classToPick'];
$search = Config::inst()->get($class, 'searchable_fields');
$searchArray = array();
$sqlQuery = new SQLQuery();
$sqlQuery->setFrom($class);
$sqlQuery->selectField('ID');
$sqlQuery->useDisjunction();
foreach ($search as $key => $value) {
if (!is_array($value)) {
if (is_string($key)) {
$sqlQuery->addWhere("{$key} LIKE '%{$request}%'");
} else {
$sqlQuery->addWhere("{$value} LIKE '%{$request}%'");
}
}
}
$results = array(array('id' => '0', 'title' => 'none selected', 'full' => "select none", 'style' => 'color:red'));
$dbResults = $sqlQuery->execute();
foreach ($dbResults as $row) {
$object = DataObject::get($class)->byID($row['ID']);
$results[] = array('id' => $object->ID, 'title' => $object->LinkTitle(), 'full' => $object->LinkTitle());
}
}
return json_encode($results);
}