cakephp中加载第三方种的一点注意的
Jun 13, 2016 am 10:54 AM
find
gt
this
user
users
cakephp中加载第三方类的一点注意的
在cakephp中,加载其他不相关的类,有三种方法,例子如下:
<?phpclass TasksController extends AppController { var $name = 'Tasks'; function index() { $this->set('tasks',$this->Task->find('all')); /** * 引用外部不相关类的第一种方法 ClassRegistry::init() * 功能:包含一个类文件,生成对象并返回对象。 $users = ClassRegistry::init("User")->find('all'); $this->set('users',$users); */ /** * 引用外部不相关类的第二种方法 Controller::loadModel() * 直接在控制器中调用Model类,并初始化成$this->Model名 $this->loadModel("User"); $users = $this->User->find('all'); $this->set('users',$users); */ /** * 引用外部不相关类的第三种方法 App::import() * 只相当于include一个类文件,初始化及调用方法都要重新来。 App::import('model','User'); $User = new User(); $this->set('users',$User->find('all')); */ }}?>
Copy after login
可以看到,第三种方法App:import是最底效率的了.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?
3 weeks ago
By 王林
Two Point Museum: All Exhibits And Where To Find Them
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?
3 weeks ago
By 王林
Two Point Museum: All Exhibits And Where To Find Them
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What are the differences between Huawei GT3 Pro and GT4?

Fix: Snipping tool not working in Windows 11

How to Fix Can't Connect to App Store Error on iPhone

OPPO Find X7 is a masterpiece! Capture your every moment with images

OPPO Find X8 Ultra core configuration exposed! Snapdragon 8 Gen4+ Extra Large Battery

What are the string search and replace techniques in Python?

How to solve the problem of docker mounting directory permissions
