PHP code example of itrn0 / php-medoo-wrapper

1. Go to this page and download the library: Download itrn0/php-medoo-wrapper 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/ */

    

itrn0 / php-medoo-wrapper example snippets




use Itrn0\MedooWrapper\MedooWrapper;
use Itrn0\SqlInterpolator\SqlInterpolator;

$db = new MedooWrapper([
    'database_type' => 'mysql',
    'database_name' => 'test',
    'server' => 'localhost',
    'username' => 'root',
    'password' => ''
]);

$usernames = ['alice', 'bob'];
$res = $db->query(function (SqlInterpolator $interp) use ($usernames) {
    return <<<SQL
        SELECT * FROM users WHERE id IN ({$interp(...$usernames)})
    SQL;
});
$users = $res->fetchAll();

// Fetch a single row from the query result set
$data = $db->fetch("SELECT * FROM `users` WHERE `name` = :name", [
    ':name' => 'John',
]);

// Returns an array containing all of the result set rows
$data = $db->fetchAll("SELECT * FROM `users`");

composer