I've created a customer model. One of the methods is called check_exists() and this takes a parameter (email address) and checks in the `customer` database table to see if the customer already exists. This method is called from the customer controller.
Now I've created a user model, and created a new method within also called check_exists(). This takes a parameter (username) and checks in the `user` database table to see if the user already exists. This method is called from the user controller.
For efficiency I am thinking I could create a global check_exists() function which accepts some additional parameters (database table and field name) and this could be used by all models. Where would be the place to put this? I had considered creating a library for it, but I did read that libraries should really be independent and not include database calls. Is this true? Is there a better place to put it? Or should I stick to creating multiple check_exists() methods in each model?
Thanks,