Welcome Guest, Not a member yet? Register   Sign In
Using common functions in multiple models
#1

[eluser]veliscorin[/eluser]
Hi guys,

I currently have several models, each with similar functions like so:
Code:
user_model->get_user_by_id($id);
book_model->get_book_by_id($id);
receipt_model->get_receipt_by_id($id);
Since they are all similar functions and return similar data, I wish to do it in such a way that I do not have to repeat these code in subsequent newer models that I create. I was thinking of doing it such a way that I shall have something like this:
Code:
some_generic_name->get_single_row($table_name, $id);
So that in my different controllers, I could use something like this:
Code:
$user = $this->some_generic_name->get_single_row('tbl_users', '1');
//or
$book = $this->some_generic_name->get_single_row('tbl_books', '1');
Is there a way to do this? Or am I not going in the direction that things are supposed to be done...

Many thanks in advance to the community =)


Messages In This Thread
Using common functions in multiple models - by El Forum - 02-07-2008, 10:18 AM
Using common functions in multiple models - by El Forum - 02-07-2008, 12:22 PM
Using common functions in multiple models - by El Forum - 02-07-2008, 02:37 PM
Using common functions in multiple models - by El Forum - 02-07-2008, 09:01 PM
Using common functions in multiple models - by El Forum - 02-07-2008, 09:05 PM
Using common functions in multiple models - by El Forum - 02-07-2008, 11:26 PM
Using common functions in multiple models - by El Forum - 02-07-2008, 11:38 PM
Using common functions in multiple models - by El Forum - 02-08-2008, 12:08 AM
Using common functions in multiple models - by El Forum - 02-08-2008, 12:44 AM
Using common functions in multiple models - by El Forum - 02-08-2008, 06:46 AM
Using common functions in multiple models - by El Forum - 02-08-2008, 06:49 AM
Using common functions in multiple models - by El Forum - 02-08-2008, 06:55 AM
Using common functions in multiple models - by El Forum - 02-08-2008, 07:10 AM
Using common functions in multiple models - by El Forum - 02-08-2008, 08:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB