1. Go to this page and download the library: Download knj/d2o 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/ */
knj / d2o example snippets
$d2o = new Wazly\D2O($dsh, $username, $password);
$sql = 'SELECT * FROM users WHERE id = :id'
$row = $d2o
->state($sql)
->run([':id' => 3])
->pick();
$dbh = new PDO($dsh, $username, $password);
$sql = 'SELECT * FROM users WHERE id = :id';
$stmt = $dbh->prepare($sql);
$stmt->execute([':id' => 3]);
$row = $stmt->fetch(PDO::FETCH_OBJ);
$d2o->state($sql)
->bind([
':role' => $role,
':limit' => [$limit, 'int'],
])
->run(); // returns $d2o
$d2o->state($sql)
->run([
':role' => $role,
':limit' => [$limit, 'int'],
]); // the same as the above
$row = $d2o->state($sql)
->run([
':role' => $role,
':limit' => [1, 'int'],
])
->pick(); // recommended if the number of rows is supposed to be 1
$result = $d2o->state($sql)
->run([
':role' => $role,
':limit' => [$limit, 'int'],
]); // recommended if the number of rows is supposed to be 2 or more
$row1 = $result->pick();
$row2 = $result->pick();
$row3 = $result->pick();