Full abstract factory template for Code Igniter models

I am creating a site where I use MongoDB as a database, I buy, I also want to use any other storage system in the future, so I would like to use the full implementation of the abstract factory template. With a full implementation, I refer to this:

  • "Database_factory" is an abstract class that should be used by client code (controller) to create a factory object.
  • "Mongodb_factory", which extends the Database_factory class.

  • The Customers abstract class, which represents a set of queries.

  • The "Mongodb_customers" class that implements the Clients class. The Mongodb_customers object must be returned by Mongodb_factory.

I know exactly how to do this with pure OO PHP. But I do not know how to combine it with the model architecture that CodeIgniter provides.

It would just be easy to have an abstract class "Clients" and then "Mongodb_customers" to implement it, but I also want to use factories.

If you need a model in CodeIgniter, you simply use the model $ this-> load-> ('my_model); "and use its functions, but how to create a factory object and make it return the specific model that you need, which you use through the interface (abstract class)?

Is there a chance to achieve this?

Thank you everybody.

+3
source share
1 answer

Hm-, db. ? , db . , factory / , . , , , , factory, , ( , , ). , factory, , ( , factory).

+1
source

All Articles