PHP code example of mateodioev / db

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

    

mateodioev / db example snippets


use Mateodioev\Db\Connection;

Connection::Prepare('DB_HOST', 'DB_PORT', 'DB_NAME', 'DB_USER', 'DB_PASS');
# or 
$dir = 'path/to/.env/file';
Connection::PrepareFromEnv($dir);

use Mateodioev\Db\Query;
$db = new Query();

// Return one afect row
$db->Exec('SELECT * FROM users'); // Simple sql query
$db->Exec('SELECT * FROM users WHERE id = :id', [':id' => 'random_id']); // With params

// Return all afect rows
$db->GetAll('SELECT * FROM users'); // Simple sql query
$db->GetAll('SELECT * FROM users WHERE id = :id', [':id' => 'random_id']); // With params