1. Go to this page and download the library: Download anax/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/ */
anax / database example snippets
/**
* Config file for Database.
*
* Example for MySQL.
* "dsn" => "mysql:host=localhost;dbname=test;",
* "username" => "test",
* "password" => "test",
* "driver_options" => [
* \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
* ],
*
* Example for SQLite.
* "dsn" => "sqlite::memory:",
* "dsn" => "sqlite:$path",
*
*/
return [
"dsn" => null,
"username" => null,
"password" => null,
"driver_options" => null,
"fetch_mode" => \PDO::FETCH_OBJ,
"table_prefix" => null,
"session_key" => "Anax\Database",
"emulate_prepares" => false,
// True to be very verbose during development
"verbose" => null,
// True to be verbose on connection failed
"debug_connect" => false,
];
/**
* Configuration file for database service.
*/
return [
// Services to add to the container.
"services" => [
"db" => [
"shared" => true,
"callback" => function () {
$db = new \Anax\Database\Database();
// Load the configuration files
$cfg = $this->get("configuration");
$config = $cfg->load("database");
// Set the database configuration
$connection = $config["config"] ?? [];
$db->setOptions($connection);
return $db;
}
],
],
];