result() as $row key problem


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
$row['SUM (table.COLUMN')]
works, but in CI using
$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.

Alias the result column in your query

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


Thank you very much. In honour I made it "AS noctrum".


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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