Use column name as the array key for db->result_array() |
[eluser]wyred[/eluser]
I'm trying to get some support for this feature: http://codeigniter.uservoice.com/forums/...sult-to-be It's already available in Kohana framework ( http://kohanaframework.org/3.1/guide/dat...ct-asarray ). CI should have it to because it helps beginners like me to fix those "SQL N+1 SELECT problem" without writing complex join queries. My current workaround is to loop through those results again: Code: $temp = $rs->result_array(); If there's any negative side to this, I'd like to hear and learn about it.
[eluser]toopay[/eluser]
Its already like that. When you use CI db lib/class, and retrieveing the result with result_array method, you get the result just like Kohana did with as_array.
[eluser]wyred[/eluser]
Really? There's no mention of it in the documentation, http://ellislab.com/codeigniter/user-gui...sults.html And even when I look at the source code, the function doesn't accept any parameters. Did I overlook something?
[eluser]toopay[/eluser]
[quote author="wyred" date="1309797074"]...the function doesn't accept any parameters.[/quote] For that helpful feature, CI db indeed doesn't support. But create an extra function/helper (like your above code) to achieve that, will be consume same memory with Kohana DB class i believe. |
Welcome Guest, Not a member yet? Register Sign In |