1. Go to this page and download the library: Download harp-orm/query 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/ */
harp-orm / query example snippets
use Harp\Query\DB;
$db = new DB('mysql:dbname=test-db;host=127.0.0.1', 'root');
$query = $db->select()
->from('users')
->where('seller', true)
->join('profiles', ['profiles.user_id' => 'users.id'])
->limit(10);
foreach ($query->execute() as $row) {
var_dump($row);
}
echo "Executed:\n";
echo $query->humanize();
use Harp\Query\DB;
$db = new DB(
'mysql:dbname=test-db;host=127.0.0.1',
'root',
'mypass',
[PDO::ATTR\_DEFAULT\_FETCH\_MODE => PDO::FETCH\_BOTH]
);
$db->getPdo();
use Harp\Query\DB;
$db = new DB('mysql:dbname=test-db;host=127.0.0.1', 'root');
$select = $db->select()
->from('users')
->column('users.*')
->where('username', 'Tom')
->whereIn('type', ['big', 'small'])
->limit(10)
->order('created_at', 'DESC');
$result = $select->execute();
foreach ($result as $row) {
var_dump($row);
}