You can query database with an array of instructions
add to App/Library/Larocket/
follow the examples below, you dont have to input all the parameters
$result = ArrayQueryBuilder::read([
'table' => 'users',
'select' => [
'users' => [
'id',
'created_at' => [
'date' => 'Y-m-d h:i',
'as' => 'created',
],
[
'count' => '',
'as' => 'count',
],
[
'concat' => ['users.id', 'users.username'],
'as' => 'concat',
],
],
'user_profile' => ['gender']
],
'filter' => ['field'],
'where' => [],
'anywhere' => '',
'order' => [
'field' => 'asc',
'field' => 'desc',
],
'limit' => 10,
'offset' => 0,
'group' => 'field',
'having' => [
'field' => ''
],
'join' => [
'left' => [
'user_profile' => ['users.id' => 'user_profile.user_id']
]
],
'if' => [
'table' => 'table',
'where' => [],
],
]);
$result = ArrayQueryBuilder::create([
'table' => '',
'set' => [],
'dup' => false,
'if' => [],
]);
$result = ArrayQueryBuilder::update([
'table' => '',
'set' => [],
'where' => [],
'inc' => [],
'dec' => [],
'if' => [],
]);
$result = ArrayQueryBuilder::exist([
'table' => '',
'set' => [],
'where' => [],
'refer' => [],
'alter' => [],
]);
$result = ArrayQueryBuilder::delete([
'table' => '',
'where' => [],
'trunc' => true,
'if' => [],
]);
18-3 support create, read, update, delete
add more attributes, but only the necessary ones