本文整理汇总了PHP中SQLSelect::setDistinct方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLSelect::setDistinct方法的具体用法?PHP SQLSelect::setDistinct怎么用?PHP SQLSelect::setDistinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLSelect
的用法示例。
在下文中一共展示了SQLSelect::setDistinct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialiseQuery
/**
* Set up the simplest initial query
*/
public function initialiseQuery()
{
// Get the tables to join to.
// Don't get any subclass tables - let lazy loading do that.
$tableClasses = ClassInfo::ancestry($this->dataClass, true);
// Error checking
if (!$tableClasses) {
if (!SS_ClassLoader::instance()->hasManifest()) {
user_error("DataObjects have been requested before the manifest is loaded. Please ensure you are not" . " querying the database in _config.php.", E_USER_ERROR);
} else {
user_error("DataList::create Can't find data classes (classes linked to tables) for" . " {$this->dataClass}. Please ensure you run dev/build after creating a new DataObject.", E_USER_ERROR);
}
}
$baseClass = array_shift($tableClasses);
// Build our intial query
$this->query = new SQLSelect(array());
$this->query->setDistinct(true);
if ($sort = singleton($this->dataClass)->stat('default_sort')) {
$this->sort($sort);
}
$this->query->setFrom("\"{$baseClass}\"");
$obj = Injector::inst()->get($baseClass);
$obj->extend('augmentDataQueryCreation', $this->query, $this);
}
示例2: distinct
/**
* Set whether this query should be distinct or not.
*
* @param bool $value
* @return DataQuery
*/
public function distinct($value)
{
$this->query->setDistinct($value);
return $this;
}