1. Go to this page and download the library: Download alksily/database 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/ */
alksily / database example snippets
Alksily\Database\Db::initialize([
[
'dsn' => 'mysql:host=HOST;dbname=DB_NAME',
'username' => 'DB_USER',
'password' => 'DB_PASS',
// additional can be passed options, server-role and pool name:
// 'option' => [
// PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'",
// PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// ],
// 'role' => 'master', // or slave
// 'pool_name' => 'default', // pool list of connections
],
// possible another connection config
// for the implementation of master-slave
]);
$stm = Alksily\Database\Db::query('SELECT * FROM `user` WHERE `age` > 23');
while ($a = $stm->fetch(PDO::FETCH_ASSOC)) {
// some action
var_dump($a);
}
$list = $db->select('SELECT * FROM `products` WHERE `price` >= 150');
$first = $db->selectOne('SELECT * FROM `products` WHERE `price` >= 150');
$affected = $db->affect('INSERT INTO `products` SET `name` = "Socks with owls", `price` = 200');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.