Пример #1
0
 public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit)
 {
     if (!is_array($from)) {
         $from = array($from);
     }
     $fromInitially = $from;
     if (!$segmentExpression->isEmpty()) {
         $segmentExpression->parseSubExpressionsIntoSqlExpressions($from);
         $segmentSql = $segmentExpression->getSql();
         $where = $this->getWhereMatchBoth($where, $segmentSql['where']);
         $bind = array_merge($bind, $segmentSql['bind']);
     }
     $joins = $this->generateJoinsString($from);
     $joinWithSubSelect = $joins['joinWithSubSelect'];
     $from = $joins['sql'];
     // hack for https://github.com/piwik/piwik/issues/9194#issuecomment-164321612
     $useSpecialConversionGroupBy = !empty($segmentSql) && strpos($groupBy, 'log_conversion.idgoal') !== false && $fromInitially == array('log_conversion') && strpos($from, 'log_link_visit_action') !== false;
     if ($useSpecialConversionGroupBy) {
         $innerGroupBy = "CONCAT(log_conversion.idvisit, '_' , log_conversion.idgoal, '_', log_conversion.buster)";
         $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit, $innerGroupBy);
     } elseif ($joinWithSubSelect) {
         $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     } else {
         $sql = $this->buildSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     }
     return array('sql' => $sql, 'bind' => $bind);
 }
Пример #2
0
 public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit)
 {
     if (!is_array($from)) {
         $from = array($from);
     }
     if (!$segmentExpression->isEmpty()) {
         $segmentExpression->parseSubExpressionsIntoSqlExpressions($from);
         $segmentSql = $segmentExpression->getSql();
         $where = $this->getWhereMatchBoth($where, $segmentSql['where']);
         $bind = array_merge($bind, $segmentSql['bind']);
     }
     $joins = $this->generateJoinsString($from);
     $joinWithSubSelect = $joins['joinWithSubSelect'];
     $from = $joins['sql'];
     if ($joinWithSubSelect) {
         $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     } else {
         $sql = $this->buildSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     }
     return array('sql' => $sql, 'bind' => $bind);
 }
Пример #3
0
 /**
  * Returns `true` if the segment is empty, `false` if otherwise.
  */
 public function isEmpty()
 {
     return $this->segmentExpression->isEmpty();
 }