- 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.
- iOS應用逆向與安全之道
- Photoshop CS6 互聯(lián)網(wǎng)應用設計教程
- Moldflow 2010完全自學與速查手冊(模流分析·成本控制)
- Photoshop CC 實戰(zhàn)入門
- Excel 2010 商務數(shù)據(jù)分析與處理(第2版)
- Oracle SQL Developer 2.1
- CorelDRAW服裝設計實用教程(第四版)
- AutoCAD 2014電氣設計從入門到精通
- MATLAB 2015從入門到精通
- 新編AutoCAD 2016從入門到精通
- Quickstart Apache Axis2
- 中文版CorelDRAW X6基礎培訓教程(第2版)
- Liferay Portal Systems Development
- Photoshop+CorelDRAW平面設計案例實戰(zhàn):從入門到精通(視頻自學全彩版)
- Apache JMeter