Skip to content

Latest commit

 

History

History
58 lines (54 loc) · 1.29 KB

Init.md

File metadata and controls

58 lines (54 loc) · 1.29 KB

Initialization

Edit config.php and set the parameters up. Choose DB driver, DB name etc

$config = require_once __DIR__ . '/config.php';

Config example for SQLite DB in memory

// config.php
return [
    'database' => [
        'driver' => 'memory',
    ]
];

Config example for SQLite DB file

// config.php
return [
    'database' => [
        'driver' => 'sqlite',
        'dbname' => 'db.db',
        'username' => '',
        'password' => '',
    ]
];

Config example for MySQL

// config.php
return [
    'database' => [
        'driver' => 'mysql',
        'dbhost' => 'localhost',
        'dbname' => _DATABASENAME_,
        'username' => _DBUSERNAME_,
        'password' => _DBPASSWORD_,
        'charset' => 'utf8',
    ]
];

Use composer autoloader

require_once __DIR__ . '/vendor/autoload.php';

use co0lc0der\QueryBuilder\Connection;
use co0lc0der\QueryBuilder\QueryBuilder;

Init QueryBuilder with Connection::make()

$query = new QueryBuilder(Connection::make($config['database'])); // $printErrors = false

// for printing errors (since 0.3.6)
$query = new QueryBuilder(Connection::make($config['database']), true)

To the Methods section

Back to doc index or readme