PHP code example of initorm / dbal

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

    

initorm / dbal example snippets


use InitORM\DBAL\Connection\Connection;

$db = new Connection([
    'driver'   => 'mysql',
    'host'     => '127.0.0.1',
    'port'     => 3306,
    'database' => 'shop',
    'username' => 'app',
    'password' => 'secret',
    'charset'  => 'utf8mb4',
]);

// Read
$user = $db->query('SELECT id, name FROM users WHERE id = :id', ['id' => 42])
           ->asAssoc()
           ->row();

// Write
$db->query(
    'INSERT INTO users (name, email) VALUES (:name, :email)',
    ['name' => 'Alice', 'email' => '[email protected]']
);
$newId = (int) $db->lastInsertId();      // forwarded to PDO