本文整理汇总了PHP中SQLQuery::setDistinct方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::setDistinct方法的具体用法?PHP SQLQuery::setDistinct怎么用?PHP SQLQuery::setDistinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::setDistinct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_metric_identifiers
/**
* Gets all of the assigned identifiers in the database
* @return array
*/
public static function get_metric_identifiers()
{
$allowedMetrics = new SQLQuery('Identifier', 'AUCMetric');
$allowedMetrics->setDistinct(true);
$result = $allowedMetrics->execute();
$identifiers = [];
foreach ($result as $row) {
$identifiers[] = $row['Identifier'];
}
return $identifiers;
}
示例2: getCSVColumns
private function getCSVColumns($flexi)
{
$columns = array('SubmittedBy' => 'Submitted By', 'IPAddress' => 'IP Address', 'Created' => 'Created');
$sql = new SQLQuery();
$sql->setFrom('FlexiFormSubmissionValue');
$sql->setSelect('"FlexiFormSubmissionValue"."Name"');
$sql->addLeftJoin('FlexiFormSubmission', '"FlexiFormSubmissionValue"."SubmissionID" = "FlexiFormSubmission"."ID"');
$sql->addWhere('"FlexiFormSubmission"."FlexiFormID" = ' . $flexi->ID);
$sql->addWhere('"FlexiFormSubmission"."FlexiFormClass" = \'' . $flexi->class . '\'');
$sql->setDistinct(true);
foreach ($sql->execute() as $row) {
$columns['Values.' . $row['Name']] = $row['Name'];
}
return $columns;
}
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-flexiform,代码行数:15,代码来源:GridFieldConfig_FlexiFormSubmission.php
示例3: augmentSQL
public function augmentSQL(SQLQuery &$query)
{
if (Config::inst()->forClass('Post')->allow_reading_spam) {
return;
}
$member = Member::currentUser();
$forum = $this->owner->Forum();
// Do Status filtering
if ($member && is_numeric($forum->ID) && $member->ID == $forum->Moderator()->ID) {
$filter = "\"Post\".\"Status\" IN ('Moderated', 'Awaiting')";
} else {
$filter = "\"Post\".\"Status\" = 'Moderated'";
}
$query->addWhere($filter);
// Filter out posts where the author is in some sort of banned / suspended status
$query->addInnerJoin("Member", "\"AuthorStatusCheck\".\"ID\" = \"Post\".\"AuthorID\"", "AuthorStatusCheck");
$authorStatusFilter = array(array('"AuthorStatusCheck"."ForumStatus"' => 'Normal'));
if ($member && $member->ForumStatus === 'Ghost') {
$authorStatusFilter[] = array('"Post"."AuthorID" = ?', $member->ID);
}
$query->addWhereAny($authorStatusFilter);
$query->setDistinct(false);
}
示例4: 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 SQLQuery(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);
}
示例5: 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;
}
示例6: modify
/**
* @param \SQLQuery $query
* @param array $data
* @return \SQLQuery
*/
public function modify(\SQLQuery $query, array $data, QueryBuilderInterface $queryBuilder)
{
$query->setDistinct(true);
return $query;
}