Help with database load design |
08-09-2017, 06:39 PM
(This post was last modified: 08-09-2017, 06:42 PM by jarmen_kell. Edit Reason: CI's forum messes up with php code syntax highlight )
I've been thru the same case just like you, years ago.
here's what i did create a "core" model, let's just call it "Coremodel" PHP Code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); this model will act as a core parent for all models that you'll create later on.notice that i put a public-static variable inside this 'core' model. later on, when you try creating models for each of your user's custom db connection, just extend from our "Coremodel" PHP Code: class Model_user1 extends Coremodel { notice that i put a private var "_DB" and then retrieve our db connection instance from "Coremodel",then put it in private var "_DB". lastly, make sure that our "Coremodel" is autoloaded from autoload config. PHP Code: $autoload['model'] = array('coremodel'); now you have all of your model's connected accordingly, without haveing to create a new connection for each models. hope this make sense. |
Messages In This Thread |
Help with database load design - by NickBrown1968 - 08-09-2017, 07:38 AM
RE: Help with database load design - by jarmen_kell - 08-09-2017, 06:39 PM
RE: Help with database load design - by phpforever2017 - 08-10-2017, 01:29 PM
RE: Help with database load design - by Diederik - 08-11-2017, 02:57 AM
RE: Help with database load design - by NickBrown1968 - 08-13-2017, 10:58 AM
RE: Help with database load design - by NickBrown1968 - 08-13-2017, 11:06 AM
|