From 11f98c904f225c611919a4bfeb42071b9268ad83 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 27 Jul 2012 11:52:50 -0500 Subject: [PATCH] Small improvement to skills mgmt query --- main/inc/lib/skill.lib.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php index 09f4c4e5a2..2dbe918d22 100644 --- a/main/inc/lib/skill.lib.php +++ b/main/inc/lib/skill.lib.php @@ -317,22 +317,21 @@ class Skill extends Model { $id_condition = ''; if (isset($id)) { $id = intval($id); - $id_condition = " WHERE id = $id"; + $id_condition = " WHERE s.id = $id"; } if (isset($parent_id)) { $parent_id = intval($parent_id); if (empty($id_condition)) { - $id_condition = "WHERE parent_id = $parent_id"; + $id_condition = "WHERE ss.parent_id = $parent_id"; } else { - $id_condition = " AND parent_id = $parent_id"; + $id_condition = " AND ss.parent_id = $parent_id"; } } - $sql = "SELECT id, name, description, parent_id, relation_type - FROM {$this->table} s INNER JOIN {$this->table_skill_rel_skill} ss ON (s.id = ss.skill_id) - $id_condition"; + $sql = "SELECT s.id, s.name, s.description, ss.parent_id, ss.relation_type". + " FROM {$this->table} s INNER JOIN {$this->table_skill_rel_skill} ss ON (s.id = ss.skill_id) $id_condition"; $result = Database::query($sql); $skills = array(); @@ -580,4 +579,4 @@ class Skill extends Model { unset($skills); return $skills_tree; } -} \ No newline at end of file +}