예제 #1
0
 /**
  * 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;
 }
 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;
 }
 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
0
 /**
  * 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
0
 /**
  * Set whether this query should be distinct or not.
  *
  * @param bool $value
  * @return DataQuery
  */
 public function distinct($value)
 {
     $this->query->setDistinct($value);
     return $this;
 }
 /**
  * @param \SQLQuery $query
  * @param array $data
  * @return \SQLQuery
  */
 public function modify(\SQLQuery $query, array $data, QueryBuilderInterface $queryBuilder)
 {
     $query->setDistinct(true);
     return $query;
 }