- 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.
- 中文版CorelDRAW X7基礎培訓教程(移動學習版)
- Adobe創意大學Illustrator產品專家認證標準教材(CS6修訂版)
- 零基礎學后期:Photoshop+Lightroom數碼照片處理從新手到高手
- UG NX 9.0中文版基礎與實例教程
- Drools JBoss Rules 5.0 Developer's Guide
- RESTful PHP Web Services
- 中文版3ds Max 2021完全自學教程
- Implementing SugarCRM 5.x
- Premiere pro CC中文版自學視頻教程
- 零基礎學會聲會影2018(全視頻教學版)
- 巧用ChatGPT高效搞定Excel數據分析
- LaTeX論文寫作教程
- Excel數據處理與分析:數據思維+分析方法+場景應用
- 數碼攝影修圖師完全手冊(第2卷)
- MODx Web Development