PHP code example of yousha / dbalite

1. Go to this page and download the library: Download yousha/dbalite 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/ */

    

yousha / dbalite example snippets


$config = [
    'host' => '127.0.0.1',
    'dbname' => 'test_database',
    'user' => 'test_username',
    'password' => 'test_password',
    'ssl_ca' => '/path/to/ca-cert.pem', // Optional: Path to SSL CA certificate
    'ssl_verify' => false,             // Optional: Disable server cert verification
];

$config = [
    'driver' => OracleDriver::class,
    'database' => [
        'host' => '127.0.0.1',
        'port' => 1521,
        'dbname' => 'test_database',
        'user' => 'test_username',
        'password' => 'test_password',
    ],
];

$config = [
    'driver' => SQLiteDriver::class,
    'database' => [
        'path' => __DIR__ . '/testdatabase.sqlite',
    ],
];

use Yousha\DBALite\Dbal;
use Yousha\DBALite\ConfigManager;

$config = new ConfigManager([
    'database' => $config,
    'migrations_dir' => __DIR__ . '/migrations', // Optional: Path to migration files.
]);

$dbal = new Dbal($config);



ousha\DBALite\ConfigManager;
use Yousha\DBALite\Dbal;

$config = new ConfigManager([
    'driver' => \Yousha\DBALite\Driver\MySQLDriver::class,
    'database' => [
        'host' => '127.0.0.1',
        'dbname' => 'test',
        'user' => 'root',
        'password' => '',
    ],
]);

$dbal = new Dbal($config);

$result = $dbal->getDriver()->query("SELECT 'Hello, DBALite!' AS message");
print_r($result);