1. Go to this page and download the library: Download mradang/mysql library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mradang / mysql example snippets
// 初始化
$config = [
'host' => 'localhost',
'port' => '3306',
'database' => 'test',
'username' => 'test',
'password' => 'test',
'charset' => 'utf8',
];
$db = new \mradang\MySQL\MySQL($config);
// 插入
$id = $db->insert_kv('logs', [
'msg' => 'test',
'created_at' => time(),
]);
// 更新
$sql = 'update logs set msg = ? where id = ?';
$rows = $db->update($sql, ['test2', 1]);
// 删除
$sql = 'delete from logs where id = ?';
$rows = $db->delete($sql, [2]);
// 查询
$sql = 'select * from logs order by id desc';
$rs = $db->select($sql, [], 1, 2);
// 单条查询
$sql = 'select * from logs where id = ?';
$log = $db->fetch($sql, [1]);
// 取值
$sql = 'select msg from logs where id = ?';
$msg = $db->value($sql, [1]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.