Skip to content

Commit

Permalink
Updates that add the table name in the where clause of the "get_other…
Browse files Browse the repository at this point in the history
…s" and "get_languages" methods of base_module_model
  • Loading branch information
David McReynolds committed Nov 16, 2014
1 parent 193643e commit 6207498
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions fuel/modules/fuel/models/base_module_model.php
Expand Up @@ -690,7 +690,8 @@ public function get_others($display_field, $id = NULL, $val_field = NULL)

if (in_array($CI->language_col, $fields))
{
$display_field = 'CONCAT('.$display_field.', " - ", '.$CI->language_col.') AS val_field';
if (strpos($display_field, '.') === FALSE) $display_field = $this->table_name.'.'.$display_field;
$display_field = 'CONCAT('.$display_field.', " - ", '.$this->table_name.'.'.$CI->language_col.') AS val_field';
$orderby = 'val_field ASC';
}
}
Expand Down Expand Up @@ -731,7 +732,7 @@ public function get_languages($field = NULL)
{
$this->db->distinct($field);
}

if (strpos($field, '.') === FALSE) $field = $this->table_name.'.'.$field;
$where[$field.' !='] = '';
$options = $this->options_list($field, $field, $where, TRUE, FALSE);
return $options;
Expand Down
8 changes: 4 additions & 4 deletions fuel/modules/fuel/models/fuel_tags_model.php
Expand Up @@ -169,17 +169,17 @@ public function options_list($key = 'id', $val = 'name', $where = array(), $orde
{
$this->db->join($this->_tables['fuel_categories'], $this->_tables['fuel_categories'].'.id = '.$this->_tables['fuel_tags'].'.category_id', 'LEFT');

if (empty($key)) $key = 'id';
if (empty($val)) $val = 'name';
if (empty($key)) $key = $this->_tables['fuel_categories'].'.id';
if (empty($val)) $val = $this->_tables['fuel_categories'].'.name';

// needed to prevent ambiguity
if (strpos($key, '.') === FALSE)
if (strpos($key, '.') === FALSE AND strpos($key, '(') === FALSE)
{
$key = $this->_tables['fuel_tags'].'.'.$key;
}

// needed to prevent ambiguity
if (strpos($val, '.') === FALSE)
if (strpos($val, '.') === FALSE AND strpos($val, '(') === FALSE)
{
$val = $this->_tables['fuel_tags'].'.'.$val;
}
Expand Down

0 comments on commit 6207498

Please sign in to comment.