[eluser]maikens55[/eluser]
I have looked into the DB_active_rec.php file and determined the problem.
The problem is caused by using cache. During the _compile_select() call, called from get(), it calls the _merge_cache function. Since the select statement is simply exploded by comma delimiters, the CONCAT_WS statement is broken up into 6 array elements. It looks like this:
array (size=32)
0 => string 'estimates.id' (length=12)
1 => string 'estimates.estimate_number' (length=25)
2 => string 'customers.name' (length=14)
3 => string 'estimates.estimate_type' (length=23)
4 => string 'CONCAT_WS("' (length=11)
5 => string '"' (length=1)
6 => string '`estimates`.`meeting_date`' (length=26)
7 => string '`estimates`.`meeting_complete`' (length=30)
8 => string '`estimates`.`delivery_complete`' (length=31)
9 => string '"meeting")' (length=10)
10 => string 'CONCAT_WS("' (length=11)
11 => string '"' (length=1)
12 => string '`estimates`.`delivery_date`' (length=27)
13 => string '`estimates`.`meeting_complete`' (length=30)
14 => string '`estimates`.`delivery_complete`' (length=31)
15 => string '"delivery")' (length=11)
16 => string 'estimates.status' (length=16)
17 => string 'estimates.price' (length=15)
18 => string 'estimates.id' (length=12)
19 => string 'estimates.estimate_number' (length=25)
20 => string 'customers.name' (length=14)
21 => string 'estimates.estimate_type' (length=23)
22 => string 'CONCAT_WS("' (length=11)
23 => string '"' (length=1)
24 => string '`estimates`.`meeting_date`' (length=26)
25 => string '`estimates`.`meeting_complete`' (length=30)
26 => string '`estimates`.`delivery_complete`' (length=31)
27 => string '"meeting")' (length=10)
28 => string '`estimates`.`delivery_date`' (length=27)
29 => string '"delivery")' (length=11)
30 => string 'estimates.status' (length=16)
31 => string 'estimates.price' (length=15)
However, on lines 1942 - 1952, it does this:
Code:
foreach ($this->ar_cache_exists as $val)
{
$ar_variable = 'ar_'.$val;
$ar_cache_var = 'ar_cache_'.$val;
if (count($this->$ar_cache_var) == 0)
{
continue;
}
$this->$ar_variable = array_unique(array_merge($this->$ar_cache_var, $this->$ar_variable));
}
Because it filters out the array using array_unique, and because more than half of the pieces of each CONCAT_WS are common due to the syntax of the function and the similarity of the parameters. most of the sections of the second call are removed from the array.
I am not certain how to fix this elegantly while not introducing any bugs. Any suggestions?