Welcome Guest, Not a member yet? Register   Sign In
Global Loader Class
#11

[eluser]bretticus[/eluser]
[quote author="whobutsb" date="1281486210"]In my projects in wouldn't be that bad to reuse the same models over and over again. I have a "Business Unit" which has the Long Name, Abbreviated Name, Address, Phone Number, etc. of the business units in my company. And most of the time I'm just copying and pasting the businessunit_model.php from one project to another. I might end up just creating a library and doing all my db calls in there using this new method.
[/quote]

Keep in mind that you can use a global library as a model for converting your business unit database entities to objects (as you suggested.) Also, I just looked in the core code. You can have a model folder that will be looked at in the system folder. But this requires that you have a MY_Loader library in your application(s). It's just a matter of adding the path to the local _ci_model_paths array in the constructor.

Code:
class MY_Loader  extends CI_Loader {
function MY_Loader()
{
parent::CI_Loader();
//add system folder to model file checks.
$this->_ci_model_paths[] = BASEPATH;
}
}

It's also worth noting that you can use the same procedure to add your own custom paths to models as well as libs and helpers. ($this->_ci_library_paths and $this->_ci_helper_paths.)

[quote author="whobutsb" date="1281486210"]
So far so good. My projects are all working correctly for the most part. But I'm still weary because I know I might find an area that is bugging out. It would've been nice to just create a Global folder and have 3 folders for models, libraries, and helpers. But I can keep experimenting and see how this goes.[/quote]

All your applications will use the same system folder anyways. So I'm not sure how this would cause problems in any way. If you upgrade CI, for example, you could just put the new codebase (system folder) in another folder and refer to it in index.php. If it doesn't work, you can easily roll it back.

I'd make a Global folder for libs and helpers at least (models if you go the MY_Loader route.) Just symlink these folders inside the respective global system folders. That way it's easy to share them between different core code bases.




Theme © iAndrew 2016 - Forum software by © MyBB