abbe98/simple-pdo
Composer 安装命令:
composer require abbe98/simple-pdo
包简介
A simpe PDO class for MariaDB and MySQL
关键字:
README 文档
README
Secure and simple library for PHP's PDO class.
Installation
Install the composer package.
composer require abbe98/simple-pdo
In define your database connection/user details using constants:
const HOST = '' // the IP of the database const DBNAME = '' // the database name to be used const USERNAME = '' // the username to be used with the database const PASSWORD = '' // the password to be used with the username
Usage Examples
Create new SimplePDO instance and open a connection:
$database = SimplePDO::getInstance();`
If there is already a open connection that one will be used automatically.
Query database and return a single row:
$database = SimplePDO::getInstance(); $database->query("SELECT `column` FROM `table` WHERE `columnValue` = :id"); $database->bind(':id', 123); $result = $database->single();
Query database and return multiply rows:
$database = SimplePDO::getInstance(); $database->query("SELECT * FROM `table`"); $result = $database->resultSet();
Insert new row in database:
$database = SimplePDO::getInstance(); $database->query("INSERT INTO `users` (name, email) VALUES (:name, :email)"); $database->bind(':name', $name); $database->bind(':name', $email); $database->execute();
Update existing row:
$database = SimplePDO::getInstance(); $database->query("UPDATE `users` SET `name` = :name WHERE `id` = :id"); $database->bind(':name', $newName); $database->bind(':id', $id); $database->execute();
统计信息
- 总下载量: 322
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-11