PHP code example of nimter / conn2db

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

    

nimter / conn2db example snippets




use Symfony\Component\Dotenv\Dotenv;
use Nimter\Helper\Conn2db\Conn2db;

$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');

$conn = new Conn2db();

$stmt = "SELECT username, pwd, avatar FROM users WHERE id = :id;";

$stmtParams = ['id' => 1];

$result = $conn->query($stmt,$stmtParams);

$data = [];

foreach($result as $x) {
    $data[] = [
        'username' => $x['username'],
        'pwd' => $x['pwd'],
        'avatar' => $x['avatar']
    ];
}