- CakePHP 1.3 Application Development Cookbook
- Mariano Iglesias
- 258字
- 2021-04-09 22:04:16
The Containable
behavior is a part of the CakePHP core, and is probably one of the most important behaviors we have to help us deal with model bindings.
Almost all CakePHP applications will benefit from its functionalities, so in this recipe we see how to enable it for all models.
Create a file named app_model.php
and place it in your app/
folder, with the following contents. If you already have one, make sure that either you add the actsAs
property shown as follows, or that your actsAs
property includes Containable
.
<?php class AppModel extends Model { public $actsAs = array('Containable'); } ?>
The Containable
behavior is nothing more and nothing less than a wrapper around the bindModel()
and unbindModel()
methods, defined in the CakePHP's Model
class. It is there to help us deal with the management of associations without having to go through a lengthy process of redefining all the associations when calling one of these methods, thus making our code much more readable and maintainable.
This is a very important point, because a common mistake CakePHP users make is to think that Containable
is involved in the query-making process, that is, during the stage where CakePHP creates actual SQL queries to fetch data.
Containable
saves us some unneeded queries, and optimizes the information that is fetched for each related model, but it will not serve as a way to change how queries are built in CakePHP.
- 中文版Photoshop入門與提高(CS6版)
- 剪映專業版(電腦版)視頻剪輯全攻略:音效添加+轉場特效+視頻制作
- Photoshop CC 實戰入門
- 好的PPT會說話:如何打造完美幻燈片
- Oracle Siebel CRM 8 User Management: LITE
- 3ds Max/MaxScript印象 腳本動畫制作基礎與應用
- ASP.NET 3.5 Application Architecture and Design
- 量化投資與FOF投資:以MATLAB+Python為工具
- Photoshop CS6從入門到精通
- Photoshop CC入門與提高
- 零基礎學Premiere Pro短視頻制作
- NX Open API編程技術
- Revit技巧精選應用教程
- Photoshop-CorelDRAW 基礎培訓教程
- UG NX 11中文版從入門到精通