[eluser]MPress[/eluser]
You cannot use the MySQL IF function within the string argument for the select active-record function. This is because it tries to reconcile the values by exploding on a ','. Although, I somehow remember this not being an issue previously... Anyways, the IF function has the syntax of: IF({cond. is met}, {return this}, {otherwise this}).
Update:
As well, the new automatic backquote feature of AR functions fails on this kind of thing: FORMAT(something, 2) since we get FORMAT(`something`, `2`). 2 must be numeric and therefore cannot be enclosed in backquotes.
Here is a temporary workaround for the first issue. Simply escape special commas by doubling up (',,'). Follow $comma_fix.
Code:
function select($select = '*', $protect_identifiers = TRUE, $comma_fix = FALSE)
{
if (is_string($select))
{
if($comma_fix && strpos($select, ',,') !== FALSE){
$select = str_replace(',,', '?~', $select);
}
$select = explode(',', $select);
}
foreach ($select as $val)
{
$val = trim($val);
if($comma_fix && strpos($val, '?~') !== FALSE){
$val = str_replace('?~', ',', $val);
}
if ($val != '*' && $protect_identifiers !== FALSE)
{
if (strpos($val, '.') !== FALSE)
{
$val = $this->dbprefix.$val;
}
else
{
$val = $this->_protect_identifiers($val);
}
}
if ($val != '')
{
$this->ar_select[] = $val;
if ($this->ar_caching === TRUE)
{
$this->ar_cache_select[] = $val;
}
}
}
return $this;
}