Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify some queries to avoid them fails with postgresql #153

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Cobalt/Helper/DropdownHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ public static function getTeams($team=null)
$query = $db->getQuery(true);
//query string
//u.id//
$query->select("t.team_id AS id,u.first_name,u.last_name,u.team_id,IF(t.name!=" . $db->quote('') . ",t.name," . $query->concatenate(array('u.first_name', $db->quote(' '), 'u.last_name')) . " AS team_name");
$query->select("t.team_id AS id,u.first_name,u.last_name,u.team_id,
CASE t.name
WHEN '' THEN " . $query->concatenate(array('u.first_name', $db->quote(' '), 'u.last_name')) . "
ELSE t.name
END AS team_name");
$query->from("#__users AS u");
$query->leftJoin("#__teams AS t on t.leader_id = u.id");
$query->where("u.role_type=" . $db->quote('manager'));
Expand Down
6 changes: 3 additions & 3 deletions src/Cobalt/Model/Formwizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public function _buildQuery()
$db = $this->getDb();
$query = $db->getQuery(true);
$query
->select("f.*," . $query->concatenate(array('user.first_name', $db->quote(' '), 'user.last_name')) . " AS owner_name")
->select("f.*," . $query->concatenate(array('users.first_name', $db->quote(' '), 'users.last_name')) . " AS owner_name")
->from("#__formwizard AS f")
->leftJoin("#__users AS user ON user.id = f.owner_id");
->leftJoin("#__users AS users ON user.id = f.owner_id");

return $query;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public function getForms()

$query->order($this->getState()->get('Formwizard.filter_order') . ' ' . $this->getState()->get('Formwizard.filter_order_Dir'));
$this->db->setQuery($query, $limitStart, $limit);

$results = $this->db->loadAssocList();

if (count($results) > 0)
Expand Down
4 changes: 2 additions & 2 deletions src/Cobalt/Model/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getCustomReportData($id = null)
$queryString .= 'stat.name as status_name,';
$queryString .= 'source.name as source_name,';
$queryString .= 'stage.name as stage_name,stage.percent,';
$queryString .= 'user.first_name, user.last_name,';
$queryString .= 'users.first_name, users.last_name,';
$queryString .= 'p.first_name as primary_contact_first_name,p.last_name as primary_contact_last_name,';
$queryString .= "p.email as primary_contact_email,p.phone as primary_contact_phone,";
$queryString .= "pc.name as primary_contact_company_name";
Expand All @@ -170,7 +170,7 @@ public function getCustomReportData($id = null)
$query->leftJoin('#__deal_status AS stat ON stat.id = d.status_id');
$query->leftJoin('#__sources AS source ON source.id = d.source_id');
$query->leftJoin('#__stages AS stage on stage.id = d.stage_id');
$query->leftJoin('#__users AS user ON user.id = d.owner_id');
$query->leftJoin('#__users AS users ON users.id = d.owner_id');
$query->leftJoin("#__people AS p ON p.id = d.primary_contact_id && p.published>0");
$query->leftJoin("#__companies AS pc ON pc.id = p.company_id && pc.published>0");

Expand Down
5 changes: 4 additions & 1 deletion src/Cobalt/Model/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ public function _buildQuery()
$query->select("u.*,ju.username,ju.email,ju.lastvisitDate as last_login,
team_leader.first_name as leader_first_name,team_leader.last_name as leader_last_name,
team.leader_id as leader_id,
IF(team.name!='',team.name," . $query->concatenate(array('team_leader.first_name', $this->db->quote(' '), 'team_leader.last_name')) . ") AS team_name");
CASE team.name
WHEN '' THEN " . $query->concatenate(array('team_leader.first_name', $this->db->quote(' '), 'team_leader.last_name')) . "
ELSE team.name
END AS team_name");
$query->from("#__users AS u");

//left join essential data
Expand Down