iassasin/fidb

为PHP提供的非常轻量且简单的数据库接口

v0.2.0 2018-11-02 17:34 UTC

This package is auto-updated.

Last update: 2024-09-24 03:19:50 UTC


README

非常简单且轻量级的数据库连接包装器,使构建查询更简单、更安全。

安装

使用composer安装fidb

composer require iassasin/fidb

用法

require_once 'vendor/autoload.php';

use Iassasin\Fidb\Connection\ConnectionMysql;

$db = new ConnectionMysql($host, $database, $user, $password);

$db->query('INSERT INTO table(num, str, txt) VALUES(%d, %s, %s)',
	123, 'string', 'and "text"'); // automatic string escaping

// build queries of any complexity with variables
$bs = $db->select()
	->column('str')
	->table('table')
	->where('num > %d', 30);

foreach ($bs->execute()->fetchAll() as $row){
	echo $row['str'];
}

更多示例请见示例