Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$this->load->model()我在模型中有很多代码,虽然模型可能会在其他地方加载,但我想通过在几乎所有使用它的地方做来确保。可以吗,还是会耗尽任何资源?即使模型已经加载?
$this->load->model()
每次调用 $this->load->model() 时都会执行构造函数,但文件本身只会加载一次。将您经常使用的模型放入 application/config/autoload.php 可能是有意义的
最好在构造函数中加载模型。所以不需要一次又一次地重复代码..