Beispiel #1
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use Braincrafted\ArrayQuery\QueryBuilder;
$thorinsCompany = [['name' => 'Bilbo Baggins', 'race' => 'Hobbit'], ['name' => 'Gandalf', 'race' => 'Wizard'], ['name' => 'Thorin Oakenshild', 'race' => 'Dwarf'], ['name' => 'Balin', 'race' => 'Dwarf'], ['name' => 'Bifur', 'race' => 'Dwarf'], ['name' => 'Bofur', 'race' => 'Dwarf'], ['name' => 'Bombur', 'race' => 'Dwarf'], ['name' => 'Dori', 'race' => 'Dwarf'], ['name' => 'Dwalin', 'race' => 'Dwarf'], ['name' => 'Fili', 'race' => 'Dwarf'], ['name' => 'Gloin', 'race' => 'Dwarf'], ['name' => 'Kili', 'race' => 'Dwarf'], ['name' => 'Nori', 'race' => 'Dwarf'], ['name' => 'Oin', 'race' => 'Dwarf'], ['name' => 'Ori', 'race' => 'Dwarf']];
$qb = new QueryBuilder();
$query = $qb->create()->select('name')->from($thorinsCompany)->where('race', 'Dwarf');
$result = $query->findAll();
print_r($result);
Beispiel #2
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use Braincrafted\ArrayQuery\QueryBuilder;
$users = [['name' => '  haXor'], ['name' => '1337PWNR'], ['name' => '     LOL  '], ['name' => 'N0b'], ['name' => 'n3rd']];
$qb = new QueryBuilder();
// Get all users with name "lol" (after trimming whitespaces and converting it lowercase)
$query = $qb->create()->select('name')->from($users)->where('name', 'lol', '=', ['trim', 'lower']);
$result = $query->findAll();
print_r($result);
// Get all users with a name of length 3 (after trimming whitespaces)
$query = $qb->create()->select('name')->from($users)->where('name', 3, '=', ['trim', 'length']);
$result = $query->findAll();
print_r($result);
// Get all users with name nerd (replace the letter 3 in the name through e)
$query = $qb->create()->select('name')->from($users)->where('name', 'nerd', '=', ['replace 3,e']);
$result = $query->findAll();
print_r($result);