Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- protected function buildQuery($mode) {
- $groupSql = '';
- if ($mode == 'result') {
- if ($this->selector->mode == 'objects') {
- $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');
- } else {
- $this->queryColumns = array('h.id as id', 'h.rel as pid', 'h.obj_id as oid');
- $groupSql = 'GROUP BY oid';
- }
- } else {
- $this->queryColumns = ($this->selector->mode == 'objects') ? array('COUNT(o.id)') : array('COUNT(h.id)');
- }
- if ($this->selector->option('root')->value) {
- return $this->buildRootQuery($mode);
- }
- $columnsSql = $this->buildColumns();
- $limitSql = $this->buildLimit();
- $orderSql = $this->buildOrder();
- $whereSql = $this->buildWhere();
- $ljoinSql = $this->buildLeftJoins();
- $tablesSql = $this->buildTables();
- $optionsSql = $this->buildOptions($mode);
- return <<<SQL
- SELECT {$optionsSql} {$columnsSql}
- FROM {$tablesSql}
- {$ljoinSql}
- {$whereSql}
- {$groupSql}
- {$orderSql}
- {$limitSql}
- SQL;
- }
- ?>
Add Comment
Please, Sign In to add comment