particlebits/pdo
最新稳定版本:2.1.4
Composer 安装命令:
composer require particlebits/pdo
包简介
Smallest possible PDO database while being super useful
README 文档
README
Micro PDO Library
Smallest possible PDO database while still being super useful
Installation
Use Composer
"require": { "ParticleBits/pdo": "~2.0" }
Features
- Compatible with PHP 5.6 and higher!
- Tested on all versions of PHP 5.6 -> 7.4 (Not tested yet on PHP 8.x)
- No dependencies other than the PDO extension
- Tiny footprint
Usage
Examples selecting, inserting, updating and deleting data from or into the users table.
require_once 'vendor/autoload.php'; $dsn = 'mysql:host=your_db_host;dbname=your_db_name;charset=utf8'; $usr = 'your_db_username'; $pwd = 'your_db_password'; $pdo = new \Pb\PDO\Database($dsn, $usr, $pwd); // SELECT * FROM users WHERE id = ? $stmt = $pdo ->select() ->from('users') ->where('id', '=', 1234) ->execute(); $data = $stmt->fetch(); // INSERT INTO users (id , usr , pwd) VALUES (? , ? , ?) $stmt = $pdo ->insert(['id', 'usr', 'pwd']) ->into('users') ->values([1234, 'your_username', 'your_password']); $insertId = $stmt->execute(true); // true returns insert ID // UPDATE users SET pwd = ? WHERE id = ? $stmt = $pdo ->update(['pwd' => 'your_new_password']) ->table('users') ->where('id', '=', 1234); $affectedRows = $stmt->execute(); // DELETE FROM users WHERE id = ? $stmt = $pdo ->delete() ->from('users') ->where('id', '=', 1234); $affectedRows = $stmt->execute();
Notes on the sqlsrv extension
The sqlsrv extension will fail to connect when using error mode PDO::ERRMODE_EXCEPTION (default). To connect, you will need to explicitly pass array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING) (or PDO::ERRMODE_SILENT) into the constructor, or override the getDefaultOptions() method when using sqlsrv.
Documentation
See DOCUMENTATION
Changelog
See CHANGELOG
License
See LICENSE
统计信息
- 总下载量: 5.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-28