ikitiki/pgdb
最新稳定版本:1.0.4
Composer 安装命令:
composer require ikitiki/pgdb
包简介
DB class for working with PostgreSQL
关键字:
README 文档
README
Class for working with PostgreSQL database
##Usage
Create db instance:
$db = new Ikitiki\DB(); $db->setHost('127.0.0.1'); $db->setUsername('postgres'); $db->setDbName('test');
###Make queries:
Single row query:
$res = $db->execOne( "select id, name from users where email = '%s' and status_id = %d limit 1", Ikitiki\DB::quote('john_doe@company.com'), 1 ); // Executes "select id, email from users where email = 'john_doe@company.com' and status_id = 1" // $res = [ // 'id' => 1, // 'name' => 'John Doe' // ];
Key-value queries:
$res = $db->exec("select id, name from users")->fetchArray('id', 'name'); // $res = [ // 1 => 'John Doe', // 2 => 'Richard Roe', // 3 => 'Mark Moe', // ... // ]
or
$res = $db->exec("select id, name, department_id from users")->fetchArray('id'); // $res = [ // 1 => ['name' => 'John Doe', 'department_id' => 1], // 2 => ['name' => 'Richard Roe', 'department_id' => 1], // 3 => ['name' => 'Mark Moe', 'department_id' => 2] // ... // ];
###Use complex types:
$res = $db->exec('select \'{"id":1,"name":"John Doe","department":"Sales"}\'::json as j from users')->fetchArray('j'); //$res = [ // 'id' => 1, // 'name' => 'John Doe', // 'department' => 'Sales', //]
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-21