1. Use of $uses and Loadmodel
Try not to use $uses in the cakephp1.3.x version, as this will load all the model used, consume memory and consume unnecessary time.
Instead, use Loadmodel to load it where you need to use the model. Set its Recursive property to-1 without the need for associated data.
In addition the controller default data model does not load, if Users_controller does not call Loadmodel (user), the user model and its associated model will be loaded automatically,
Just use it directly in the controller:
$this->user ...;
$this->user->role ...
Using the lazy loading technology, version 1.3 has a lazy_model that converts your App_model base class to Lazymodel,
will allow the model to actually load only where it is actually called.
2. Use of Eval and requestaction
Try not to use eval and requestaction. Eval causes a new script parsing process, and requestaction is the equivalent of issuing a new request.
Eval can be replaced with {} or $$ similar syntax, such as
Case 1
$this->{$this->modelclass}->hasfield ("country_id");
-----------------------------------------------------------------
Case 2
$foo = City;
$ $foo = Shanghai;
Requestaction Replace with View/helper
3. Cache
Where distributed data sharing is required, local data is used as memcached as possible with APC. Use parameters to specify which cache is configured in core.php using the Cache::write/read.
http://www.bkjia.com/PHPjc/478816.html www.bkjia.com true http://www.bkjia.com/PHPjc/478816.html techarticle 1, the use of $uses and Loadmodel in the cakephp1.3.x version as far as possible not to use $uses, because this will all load the model used to occupy memory and consume unnecessary time. Contrary to the need to make ...