jeidison/native-query
最新稳定版本:0.12.0
Composer 安装命令:
composer require jeidison/native-query
包简介
Laravel package for save native query in external file.
README 文档
README
$ composer require jeidison/native-query
Publish Settings
$ php artisan vendor:publish --provider="Jeidison\NativeQuery\Provider\NativeQueryServiceProvider"
This will add the nativequery.php file in your config directory with the following contents:
return [ 'path-sql' => database_path('native-query'), 'type' => Jeidison\NativeQuery\Enums\FileType::PHP, ];
And this will add the native-query.xml file in your database directory with the following contents:
SQL in file XML
<query name="findTab1"> SELECT * FROM TAB1 WHERE PAR1 = ? </query>
And this will add the native-query.php file in your database directory with the following contents:
SQL in file PHP
CONST findTab1 = " SELECT * FROM TAB1 WHERE PAR1 = :par1 ";
Add Trait in model
... class ModelX extends Model { use HasNativeQuery; protected $queryFile = '/path/file-with-queries'; ... }
Executing SQL
ModelX::nativeQuery('findTab1')->param('par1', 'value1')->param('par2', 'value2')->exec(); ModelX::nativeQuery('findTab1')->param(['par1' => 'value1'])->exec(); ModelX::nativeQuery('findTab1')->param(['par1' => 'value1'])->->debug(); NativeQuery::query('findTab1') ->queryFile('/path/file-with-queries') ->param('par1', 'value1') ->exec();
统计信息
- 总下载量: 2.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-27