From 2727fc4abc33fabc66db5d5220e4ceae20d5f5c8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 15 Apr 2011 06:50:48 +0000 Subject: [PATCH] * Addressbook/PostgreSQL: fixed SQL error when checking "use whole query" --- addressbook/inc/class.addressbook_sql.inc.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index c646e08d0e..029c82f57f 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -441,7 +441,7 @@ class addressbook_sql extends so_sql break; } // postgres requires that expressions in order by appear in the columns of a distinct select - if ($this->db->Type != 'mysql' && preg_match_all("/([a-zA-Z_.]+) *(<> *''|IS NULL|IS NOT NULL)/u",$order_by,$all_matches,PREG_SET_ORDER)) + if ($this->db->Type != 'mysql' && preg_match_all("/([a-zA-Z_.]+) *(<> *''|IS NULL|IS NOT NULL)? *(ASC|DESC)?(,|$)/ui",$order_by,$all_matches,PREG_SET_ORDER)) { if (!is_array($extra_cols)) $extra_cols = $extra_cols ? explode(',',$extra_cols) : array(); foreach($all_matches as $matches) @@ -451,8 +451,7 @@ class addressbook_sql extends so_sql { $table = ($matches[1] == $this->extra_value ? $this->extra_table : $this->table_name).'.'; } - $extra_cols[] = $table.$matches[1]; - $extra_cols[] = $table.$matches[0]; + $extra_cols[] = $table.$matches[1].' '.$matches[2]; //_debug_array($matches); if (!empty($order_by) && $table) // postgres requires explizit order by {