Skip to content

Instantly share code, notes, and snippets.

@wilcorrea
Created November 23, 2016 00:01
Show Gist options
  • Select an option

  • Save wilcorrea/95c66f9c0d2be20c0c502907db30af80 to your computer and use it in GitHub Desktop.

Select an option

Save wilcorrea/95c66f9c0d2be20c0c502907db30af80 to your computer and use it in GitHub Desktop.
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
/** @noinspection PhpIncludeInspection */
$options = include dirname(__DIR__) . '/config/database.php';
$qb = new Hero\QueryBuilder($options);
#INSERT
$qb
->table('users')
->fields(['nome', 'login', 'password'])
->insert(['William', 'wilcorrea', crypt('senha')]);
#SELECT
$qb
->table('users') // poderia não informar, pois já está "salvo"
->fields(['id', 'nome', 'login', 'password'])
->select();
# UPDATE
$qb
->table('users') // poderia não informar, pois já está "salvo"
->fields(['nome'])
->where(['id = ?'])
->update(['William Correa'], [2]);
#DELETE
$qb
->table('users') // poderia não informar, pois já está "salvo"
->where(['id = ?'])
->delete([1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment