nickyeoman / php-mysql-helper
在PHP 8中使用MySQL时使生活更加简单
2.3.0
2023-02-08 06:51 UTC
README
PHP 8的MySQL助手类
查看:https://www.nickyeoman.com/blog/php/php-mysql-insert-from-array/
composer:https://packagist.org.cn/packages/nickyeoman/php-mysql-helper
使用方法
连接
以下是如何连接到数据库的示例。
require_once 'vendor/autoload.php'; // Composer USE Nickyeoman\Dbhelper; $db = new Nickyeoman\Dbhelper\Dbhelp('127.0.0.1', 'username', 'thePassword', 'databaseName', '3306'); $db->close();
更新一行
$array = array( 'id' => 'unique_key', 'content' => 'data value' ) $id = 'id'; // The key of the array to use as the lookup $db->update("name_of_db_table, $array, $id);