In the queryclass is missing some addJoin function

Registered by Adrian Liechti on 2012-02-15

To make some performance improvements it is necessary to add Joins individual to the parameters that are given.

example:
class GuestGenerator_readGuestGroup extends PHPDS_query
{
 protected $sql = "
  SELECT
   gg.*
  FROM
   _db_GuestGenerator_guest_group AS gg
   LEFT JOIN _db_GuestGenerator_user_groups_has_guest_group AS ag USING(guest_group_id)
   LEFT JOIN _db_core_user_extra_groups AS eg USING(user_group_id)
    ";

 protected $where = "";
 protected $groupby = "gg.guest_group_id";

 public function extraBuild($parameters = null) {

  if (isset($parameters['removed'])) {
   $this->addWhere("gg.removed = '%(removed)u'");
  }
  if (isset($parameters['userId'])) {
   $this->addWhere("eg.user_id = '%(userId)u'");
   // the JOINS only needed when the user-id is given
   // otherwise it does not need the JOINS
   // it can be something like this, to add the Joins:
   // $this->addJoin('LEFT', '_db_GuestGenerator_user_groups_has_guest_group', 'guest_group_id');
   // $this->addJoin('LEFT', '_db_core_user_extra_groups', 'user_group_id');
  }

  return parent::extraBuild($parameters);
 }
}

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
Greg
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.