macagua/yii-cadvancedarbehavior
Composer 安装命令:
composer require macagua/yii-cadvancedarbehavior
包简介
Fork of Yii 1.1 CAdvancedArBehavior (Advanced functions for Active Record implementation) by thyseus
关键字:
README 文档
README
Fork of Yii 1.1 CAdvancedArBehavior (Advanced functions for Active Record implementation) by thyseus.
Yii 1.1: cadvancedarbehavior
The CAdvancedArBehavior extension adds up some functionality to the default possibilites of yii´s ActiveRecord implementation. At the moment it is able to automatically save MANY_MANY relation objects when save()-ing an Object.
Changelog ¶
Version 0.3 added 25. 05. 2011 by thyseus
- added $ignoreRelations to ignore specified relations. The Behavior will take all found many2many relations by default. Specify exceptions in this array.
- fixes all the bugs and glitches found in the discussion
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.1 or above
Installation ¶
To use this extension, just copy this file to your extensions/ directory, add 'import' => 'application.extensions.CAdvancedArBehavior', [...] to your config/main.php and add this behavior to each model you would like to inherit the new possibilities.
Usage ¶
public function behaviors(){
return array( 'CAdvancedArBehavior' => array(
'class' => 'application.extensions.CAdvancedArBehavior'));
}
Possibilities so far: ¶
Better support of MANY_TO_MANY relations: ¶
When we have defined a MANY_MANY relation in our relations() function, we are now able to add up instances of the foreign Model on the fly while saving our Model to the Database. Let´s assume the following Relation:
Post has: 'categories'=>array(self::MANY_MANY, 'Category', 'tbl_post_category(post_id, category_id)')
Category has: 'posts'=>array(self::MANY_MANY, 'Post', 'tbl_post_category(category_id, post_id)')
Now we can use the attribute 'categories' of our Post model to add up new rows to our MANY_MANY connection Table:
$post = new Post();
$post->categories = Category::model()->findAll();
$post->save();
This will save our new Post in the table Post, and in addition to this it updates our N:M-Table with every Category available in the Database.
We can further limit the Objects given to the attribute, and can also go the other Way around:
$category = new Category();
$category->posts = array(5, 6, 7, 10);
$category->save();
We can pass Object instances like in the first example, or a list of integers that representates the Primary key of the Foreign Table, so that the Posts with the id 5, 6, 7 and 10 get´s added up to our new Category.
5 Queries will be performed here, one for the Category-Model and four for the N:M-Table tbl_post_category. Note that this behavior could be tuned further in the future, so only one query get´s executed for the MANY_MANY Table.
We can also pass a single object or an single integer:
$category = new Category();
$category->posts = Post::model()->findByPk(12);
$category->posts = 12;
$category->save();
Change Log ¶
January 30, 2010 ¶
Version 0.2 Code Cleanup, Bugfixes and added save() support
January 28, 2010 ¶
- Initial release.
macagua/yii-cadvancedarbehavior 适用场景与选型建议
macagua/yii-cadvancedarbehavior 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「Active Record」 「extension」 「relation」 「relations」 「ar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 macagua/yii-cadvancedarbehavior 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 macagua/yii-cadvancedarbehavior 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 macagua/yii-cadvancedarbehavior 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.
PHP Interface for Babel Street Text Analytics
Store your language lines in the database, yaml or other sources
A Symfony extension to get active class base on current bundle/controller/action
LDAP user provider bundle for Symfony 6.4
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: New
- 更新时间: 2015-07-29