From 549626cbf9d92b29d52c5a9194d206ca7b5f1876 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 8 Apr 2010 22:13:22 +0000 Subject: [PATCH] Add some extra handling for potentially ambiguous columns in --- etemplate/inc/class.so_sql_cf.inc.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/etemplate/inc/class.so_sql_cf.inc.php b/etemplate/inc/class.so_sql_cf.inc.php index aa74f5c547..62d06df949 100644 --- a/etemplate/inc/class.so_sql_cf.inc.php +++ b/etemplate/inc/class.so_sql_cf.inc.php @@ -457,6 +457,15 @@ class so_sql_cf extends so_sql } } } + // replace ambiguous column with (an exact match of) table_name.column + if(is_array($only_keys)) { + foreach($only_keys as $key => &$col) { + if(is_numeric($key) && in_array($col, $this->db_cols)) { + $col = $this->table_name .'.'.array_search($col, $this->db_cols); + } + } + } + // check if we order by a custom field --> join cf table for given cf and order by it's value if (strpos($order_by,self::CF_PREFIX) !== false && preg_match('/'.self::CF_PREFIX.'([^ ]+) (asc|desc)/i',$order_by,$matches))