简体   繁体   中英

Using codeigniter Models in another non-codeigniter project

I have 2 projects accessing the same DB. One is with CodeIgniter, the other is a home made mvc framework. I'd like to use the same Model layer.

Is it possible to access Codeigniter Models from another project?

我不确定您为什么要同时从两个不同的框架访问同一数据库(听起来像是灾难的配方),但是总的来说,我会说“不”。

What you actually want is not the model itself, You actually want the active records class located in /system/database/DB_active_rec, as that's the most common usage.

That class extends CI_DB_driver

This class accepts the config parameter for the DB(connection information).

You then want to extract the drivers themselves being used for the specific database you're working, the drivers can found at /system/database/drivers.

CI->model simply loads the DB_active_rec , that's why you need to do $this->db->insert()

I've never did so myself, But I don't see any major dependencies in the files themselves. I might have missed something though

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM