inglar/sql-builder
Composer 安装命令:
composer require inglar/sql-builder
包简介
README 文档
README
Composer
Open a command console, enter your project directory and execute the following command to download the latest stable version of this package:
$ composer require inglar/sql-builder
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Supported Adapters
SqlBuilder supports the following database adapters:
- MySQL (specify mysql)
- PostgreSQL (specify pgsql)
Usage
Simple select
$builder = new SqlBuilder('pgsql'); $select = $builder->select() ->column('*') ->from('table') ->where('id = :id') ->bindParam(':id', 123); echo $select; print_r($select->getBindParams());
The above example will output:
SELECT * FROM "table" WHERE id = :id
Array
(
[:id] => 123
)
Select with join
$builder = new SqlBuilder('pgsql'); $select = $builder->select() ->column('*') ->from('table') ->join($builder->join('table2', "table2.user_id = table.id") ->where('id = :id') ->bindParam(':id', 123); echo $select; print_r($select->getBindParams());
The above example will output:
SELECT * FROM "table" JOIN "table2" ON table2.user_id = table.id WHERE id = :id
Array
(
[:id] => 123
)
统计信息
- 总下载量: 254
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-23