yusrub/database-mysqli-interface

使用 MySqli 的基本数据库接口

1.0.0 2019-06-08 18:09 UTC

This package is auto-updated.

Last update: 2024-09-12 04:18:42 UTC


README

MySqli 接口是 PHP 代码,用于执行基本的 CRUD 操作。

安装

使用 composer 安装 database-mysqli-interface。

composer require yusrub/database-mysqli-interface

使用


require 'vendor/autoload.php';

$database = new Database('host', 'dbname', 'username', 'password'); # connect to database

# select all records from table
$database->select('tableName');
# apply where condition while selecting records from table where condtion can be string/array
$database->select('tableName', 'id = 5');
#multiple condition
$database->select('tableName', array(id => 5, age => 23));
#limit the records
$database->select('tableName', 'id = 5', $limit=5);
#insert the records
$database->insert('table',array(field1=>value1, field2=>value2))
#update the records
$database->update('table',array(field1=>value1, field2=>value2), 'condition_field = 2')
#delete the records
$database->delete('table', 'condition_field = 2')
$database->delete('table', array('condition_field => [1,2]))


贡献

欢迎拉取请求。对于重大更改,请先打开一个问题来讨论您想进行哪些更改。

请确保根据需要更新测试。

许可证

MIT