sy / db
基于PDO的简单数据库层
1.3.0
2023-04-07 14:05 UTC
Requires
- php: >=5.6.0
- psr/log: ^1.1
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-09-07 17:12:10 UTC
README
基于PDO的数据库层
安装
使用以下命令安装最新版本
composer require sy/db
基本用法
<?php use Sy\Db\Gate; // connection $this->gate = new Gate('sqlite:' . __DIR__ . '/database.db'); // create table $this->gate->execute(' CREATE TABLE test_table ( id INTEGER PRIMARY KEY, name TEXT NOT NULL ) '); // insert $this->gate->insert('test_table', ['id' => 1, 'name' => 'hello']); // select $res = $this->gate->queryAll('SELECT * FROM test_table', PDO::FETCH_ASSOC); print_r($res);
输出
Array
(
[0] => Array
(
[id] => 1
[name] => hello
)
)