hypercode/query

With that, you can use PHP to create SQL query.

1.0.0 2020-12-30 21:25 UTC

This package is auto-updated.

Last update: 2024-10-17 20:37:06 UTC


README

This project is, basically, a SQL query constructor. With that, you can use PHP to create SQL query with a more practical method practical

Exemples of SELECT

A select table query

$query = new Query;
$query->select('tabela');

A select table query with a specific fields

$query = new Query;
$query->select('tabela','name, age, another');

A select table query, but show just a one result

$query = new Query;
$query->select('tabela')->limit(1);

Click here to see more functions to use on select

A select table query, with a where condition.

$query = new Query;
$query->select('tabela')->where(['id' => 1]);
$query->select('tabela')->where(['nome' => 'Antonio']);

Click here to see more about Where conditions

Exemples of INSERT

A insert values query

$query = new Query;
$query->insert('tabela', ['id','name','age', 'created_at']);
$query = new Query;
$query->insert('tabela', ['id','name','age', 'created_at'])
->addValue(1,'Charles',18, 'NOW()')
->addValue(1,'Kevin', 10, time());

Click here to see more about insert method

Exemples of DELETE

A delete query

$query = new Query;
$query->delete('tabela');
$query = new Query;
$query->delete('tabela')->where(['id' => 10]);

Exemples of UPDATE

A update query

$query = new Query;
$query->update('tabela')->set('name','Gabriel');

$query->update('tabela')
    ->set('id',1)
    ->set('name','Gabriel')->where(['id' => 1]);