jayparmar271/cakephp-magic-query
Composer 安装命令:
composer require jayparmar271/cakephp-magic-query
包简介
MagicQuery plugin for CakePHP
README 文档
README
Simple query builder made with CakePHP
Requirements
- CakePHP 3.5+
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require jayparmar271/cakephp-magic-query
Usage
- Add behavior in your table. (../src/Model/Table/UsersTable.php)
$this->addBehavior('MagicQuery.Query');
- Use getRecord() to get single record.
$this->Users->getRecord(['name'], ['id' => '1']);
To set default options:
- Create new config file and add your default options. (/config/magic_query.php)
return [ 'MagicQuery' => [ 'limit' => 2, 'page' => 1, 'orderBy' => ['id' => 'ASC'], 'hydrate' => false, 'validate' => true, ], ];
- Load into your bootstrap.php (/config/bootstrap.php)
/* * Load magic query file */ if (file_exists(CONFIG . 'magic_query.php')) { Configure::load('magic_query'); }
That's all. Enjoy!
You can find more examples here.
License
The MIT License. Please see License File for more information.
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-05