fixed MsSQL problem: DISTINCT on text column in function get_installed_charsets

This commit is contained in:
Ralf Becker 2004-09-19 12:53:05 +00:00
parent f360253fb2
commit c2b14a5f85

View File

@ -234,7 +234,13 @@
{ {
if (!is_array($this->charsets)) if (!is_array($this->charsets))
{ {
$this->db->query("SELECT DISTINCT l.lang,ln.lang_name,l.content AS charset FROM phpgw_lang l,phpgw_languages ln WHERE l.lang = ln.lang_id AND l.message_id='charset'",__LINE__,__FILE__); $distinct = 'DISTINCT';
switch($this->db->Type)
{
case 'mssql':
$distinct = ''; // cant use distinct on text columns (l.content is text)
}
$this->db->query("SELECT $distinct l.lang,lx.lang_name,l.content AS charset FROM phpgw_lang l,phpgw_languages lx WHERE l.lang = lx.lang_id AND l.message_id='charset'",__LINE__,__FILE__);
if (!$this->db->num_rows()) if (!$this->db->num_rows())
{ {
return False; return False;
@ -242,8 +248,11 @@
while ($this->db->next_record()) while ($this->db->next_record())
{ {
$data = &$this->charsets[$charset = strtolower($this->db->f('charset'))]; $data = &$this->charsets[$charset = strtolower($this->db->f('charset'))];
$data .= ($data ? ', ' : $charset.': '). $lang = $this->db->f('lang_name').' ('.$this->db->f('lang').')';
$this->db->f('lang_name').' ('.$this->db->f('lang').')'; if ($distinct || strstr($data,$lang) === false)
{
$data .= ($data ? ', ' : $charset.': ').$lang;
}
} }
} }
return $this->charsets; return $this->charsets;