using aliases does not help, because the problem occurs before the
"as"... the problem is the "." and the "," in the function. This
causes cake to think that a new table/column begins and this messes up
the array, I think.
So if I us an alias, the array still will have the assosiation
"my_custom_function(users" instead of the alias...
I made another test with an alias and Im giving you the print_r of the
resulting array:
SQL Query:
SELECT
ol.onenumber,
ol.secondnumber,
ol.onedate,
i.seconddate,
my_custom_function(ol.onenumber, 'GER') AS aliastest,
c.name1,
c.postcode,
c.town,
stl.textdescr,
con.datefrom,
con.dateto,
from
onetable ol,
anothertable i,
thirdtable stl,
company c,
contract con
where .....
And the answer (print_r) was:
Array (
[0] => Array (
[ol] => Array (
[onenumber] => 25
[secondnumber] => 41
[onedate] => 2008-05-19 00:00:00 )
[i] => Array ( [seconddate] => 2008-06-19 11:10:17 )
[my_custom_function(ol] => Array ( [onenumber] =>
somereturnvalue )
[0] => Array ( [aliastest] => name1value)
[c] => Array (
[name1] => 12345
[postcode] => Geneva
[town] => some text )
[stl] => Array ( [descr] => 2012-05-31 00:00:00 )
[con] => Array ( [datefrom] => 2012-05-31 00:00:00 )
[1] ....
......
So, what happened?
Everything is fine until the column where the return value from the
function should be. There cake thinks that there is a table called
"my_custom_function(ol" with a column name "onenumber". This is
because of the "." between the first parameter (ol.onenumber).
Then comes a "," , so cake thinks "Ah, there must be the next
table.column combination!" and he finds "'Ger'"... ok, so what to do
now?
Cake thinks 'Ger' is some column name without a specified table... so
he just adds a new sub-array with the name [0] and puts in the alias
name as columnname. [aliastest]
If I had NOT specified an alias, he would just use the normal column
name (or that what he thinks is a column name), that would be GER.
Afterwards its messed up: All values are shifted by one position
upwards, so:
name1 holds the value of postcode
postcode holds the value of town
town holds the value of str.descr
descr holds the value of datefrom
datefrom holds the value of dateto
And now the best at the end: The value of dateto is completly missing.
Sorry about this long text, but I thought showing a real example might
show the problem the best ;-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---