Author: ralfbecker
New Revision: 34614
URL: http://www.egroupware.org/viewvc/egroupware?rev=34614&view=rev
Log:
- SyncML/Calendar/PostgreSQL: fixed SQL error when searching participants (SELECT DISTINCT requires ORDER-BY-expressions to be in SELECT-list)
Modified:
branches/1.8/addressbook/inc/class.addressbook_sql.inc.php
Modified: branches/1.8/addressbook/inc/class.addressbook_sql.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/branches/1.8/addressbook/inc/class.addressbook_sql.inc.php?rev=34614&r1=34613&r2=34614&view=diff
— branches/1.8/addressbook/inc/class.addressbook_sql.inc.php (original)
+++ branches/1.8/addressbook/inc/class.addressbook_sql.inc.php Mon Apr 11 14:10:23 2011
@@ -432,17 +432,25 @@
break;
}
// postgres requires that expressions in order by appear in the columns of a distinct select
-
if ($this->db->Type != 'mysql' && preg_match("/([a-zA-Z_.]+)<>''/",$order_by,$matches))
-
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 (!is_array($extra_cols)) $extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
-
$extra_cols[] = $matches[1]; -
$extra_cols[] = $matches[1]."<>''"; -
//_debug_array($matches[1]); -
if (!empty($order_by) && $matches[1] != 'extra_order.contact_value' && stripos($matches[1],'.')===false) // postgres requires explizit order by -
{ -
$order_by = str_replace($matches[1],'egw_addressbook.'.$matches[1],$order_by); -
} -
//_debug_array($order_by);
-
foreach($all_matches as $matches) -
{ -
$table = ''; -
if (strpos($matches[1],'.') === false) -
{ -
$table = ($matches[1] == $this->extra_value ? $this->extra_table : $this->table_name).'.'; -
} -
$extra_cols[] = $table.$matches[1]; -
$extra_cols[] = $table.$matches[0]; -
//_debug_array($matches); -
if (!empty($order_by) && $table) // postgres requires explizit order by -
{ -
$order_by = str_replace($matches[0],$table.$matches[0],$order_by); -
} -
} -
//_debug_array($order_by); _debug_array($extra_cols); } } // add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin)
Xperia™ PLAY
It’s a major breakthrough. An authentic gaming
smartphone on the nation’s most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs