result() as $row key problem

#1
[eluser]Unknown[/eluser]
Hi.

I'm doing my first project in CI and I copied over a long mysql query from previous work. The result() it produces is an array with a SUM(table.COLUMN) key. Normally with PHP fetching
Code:
$row['SUM (table.COLUMN')]
works, but in CI using
Code:
$row->SUM (table.COLUMN)
it interprets it as "undefined method stdClass::SUM()".

I have spent all afternoon trying whatever I could think of to call the key differently. Can anyone help me out? I am still wondering if I should learn the active records method of producing queries but I am afraid that in the end I will be missing functionality and always be reverting to mysql queries anyway. Thanks anyone.

#2
[eluser]danmontgomery[/eluser]
Alias the result column in your query

Code:
SELECT SUM(table.column) AS some_col ...

Code:
$row->some_col

#3
[eluser]Unknown[/eluser]
Thank you very much. In honour I made it "AS noctrum".

#4
[eluser]danmontgomery[/eluser]
ha!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.