PHP code example of hasirciogli / hdb

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

    

hasirciogli / hdb example snippets


interface DatabaseConfigInterface
{
    const DB_HOST = 'localhost';
    const DB_NAME = 'your_database_name';
    const DB_USER = 'your_username';
    const DB_PASS = 'your_password';
}

use Hasirciogli\Hdb\Database;
use MyProject\DatabaseConfig; // Replace with your config class path

$db = Database::cfun(new DatabaseConfig());

$users = $db->Select('users')
            ->Where('isActive', true)
            ->OrderBy('username', 'ASC')
            ->Get('all'); // Get all results as an array

$userId = 123;
$user = $db->Select('users')
            ->Where('id', $userId)
            ->Get(); // Get a single user row