1. Go to this page and download the library: Download jonathanbak/mysqlilib 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/ */
jonathanbak / mysqlilib example snippets
$DB = new MySQLiLib($host, $user, $password, $dbName);
$query = "SELECT * FROM test";
$row = $DB->fetch($query);
var_dump($row);
$query = "SELECT * FROM test WHERE id < ?";
$row1 = $DB->fetch($query, [5]);
$row2 = $DB->fetch($query, [5]);
var_dump($row1 === $row2); // false (같은 쿼리 → 다음번 데이터 가져옴)
$query = "SELECT * FROM test WHERE id < ?";
$row1 = $DB->fetchOne($query, [5]);
$row2 = $DB->fetchOne($query, [5]);
var_dump($row1 === $row2); // true (같은 쿼리 → 같은 결과)
$query = "SELECT * FROM test WHERE id = ?";
$rows = [];
while ($row = $DB->fetch($query, [11])) {
$rows[] = $row;
}
$query = "SELECT * FROM test WHERE name LIKE '??%'";
$rows = [];
while ($row = $DB->fetch($query, ['테스트'])) {
$rows[] = $row;
}
$query = "SELECT * FROM test WHERE name LIKE ?";
$rows = [];
while ($row = $DB->fetch($query, ['테스트%'])) {
$rows[] = $row;
}
var_dump($rows);
$query = "SELECT * FROM test WHERE id > :id AND name = :name";
$params = [
'id' => 10,
'name' => '홍길동'
];
$rows = [];
while ($row = $DB->fetch($query, $params)) {
$rows[] = $row;
}
var_dump($rows);
$DB->query("INSERT INTO test SET id = ?, reg_date = ?", [33, date("Y-m-d H:i:s")]);
$DB->query("DELETE FROM test WHERE id = ?", [33]);
try {
$DB->query("INSERT INTO test SET id = ?", [33]);
} catch (\MySQLiLib\Exception $e) {
echo "에러: " . $e->getMessage();
}
$DB->bind_param('i');
$DB->query("INSERT INTO test SET id = ?, reg_date = ?", [33, date("Y-m-d H:i:s")]);
$DB->bind_param('i');
$DB->query("DELETE FROM test WHERE id = ?", [33]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.