Extending DB_Result |
[eluser]Unknown[/eluser]
I posted this thread in "Ignite Code" and didn't receive any reply, I hope maybe someone here will be able to help me. Sorry for spamming. I have a very needed db function that I’m using in other projects that are not based on CodeIgniter. When using a function to return rows from a query (same like $res->result_array()), I give an extra parameter to be used as index field for the array keys. For example, if I have countries table, with code & name, instead of (example syntax): countries[0] = array(code: US, name: united states) countries[1] = array(code: TH, name: thailand) I want to receive (by calling the function $res->result_array(‘code’)): countries[‘US’] = array(code: US, name: united states) countries[‘TH’] = array(code: TH, name: thailand) To add this functionality, I need to override DB_Result->result_array() I tried to find simple ways to do it, but couldn’t. I read http://codeigniter.com/wiki/Extending_Database_Drivers/ but it didn’t help. If anyone can help with a solution, I’ll be very happy. I believe this functionality should be part of CodeIgniter core code, since it’s very useful and doing it in the core saves a lot of extra processing, but I’ll settle for a solution to extend DB_Result ![]() |
Messages In This Thread |
Extending DB_Result - by El Forum - 09-24-2009, 01:09 AM
Extending DB_Result - by El Forum - 09-24-2009, 01:51 AM
Extending DB_Result - by El Forum - 09-24-2009, 05:15 AM
|