daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. protected function buildQuery($mode) {
  3.     $groupSql = '';
  4.  
  5.     if ($mode == 'result') {
  6.         if ($this->selector->mode == 'objects') {
  7.             $this->queryColumns = array('o.id as id', 'o.name as name', 'o.type_id as type_id', 'o.is_locked as is_locked', 'o.owner_id as owner_id', 'o.guid as guid');            
  8.         } else {
  9.             $this->queryColumns = array('h.id as id', 'h.rel as pid', 'h.obj_id as oid');
  10.             $groupSql = 'GROUP BY oid';
  11.         }
  12.     } else {
  13.         $this->queryColumns = ($this->selector->mode == 'objects') ? array('COUNT(o.id)') : array('COUNT(h.id)');
  14.     }
  15.  
  16.     if ($this->selector->option('root')->value) {
  17.         return $this->buildRootQuery($mode);
  18.     }
  19.  
  20.     $columnsSql = $this->buildColumns();
  21.     $limitSql = $this->buildLimit();
  22.     $orderSql = $this->buildOrder();
  23.     $whereSql = $this->buildWhere();
  24.     $ljoinSql = $this->buildLeftJoins();
  25.     $tablesSql = $this->buildTables();
  26.     $optionsSql = $this->buildOptions($mode);
  27.  
  28.     return <<<SQL
  29.         SELECT {$optionsSql} {$columnsSql}
  30.         FROM {$tablesSql}
  31.             {$ljoinSql}
  32.             {$whereSql}
  33.             {$groupSql}
  34.             {$orderSql}
  35.             {$limitSql}
  36.         SQL;
  37. }
  38. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top