Readme
This commit is contained in:
68
Readme.md
Normal file
68
Readme.md
Normal file
@ -0,0 +1,68 @@
|
||||
# QueryBuilder
|
||||
|
||||
## Requirements
|
||||
+ PHP 8+ (Should work with 7+, but haven't tested it).
|
||||
+ `Psr\Container\ContainerInterface` implementation like [`php-di/php-di`](https://packagist.org/packages/php-di/php-di).
|
||||
|
||||
## Installation
|
||||
|
||||
```composer.json```
|
||||
```
|
||||
{
|
||||
...
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"path": "https://git.provm.cl/ProVM/query_builder.git"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
...
|
||||
"provm/query_builder": "^1.0",
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
```
|
||||
$container->set(ProVM\Concept\Database\Query\Select::class, function(Psr\Container\ContainerInterface $container) {
|
||||
return $container->get(ProVM\Database\Query\MySQL\Select::class);
|
||||
});
|
||||
$container->set(ProVM\Concept\Database\Query\Insert::class, function(Psr\Container\ContainerInterface $container) {
|
||||
return $container->get(ProVM\Database\Query\MySQL\Insert::class);
|
||||
});
|
||||
$container->set(ProVM\Concept\Database\Query\Update::class, function(Psr\Container\ContainerInterface $container) {
|
||||
return $container->get(ProVM\Database\Query\MySQL\Update::class);
|
||||
});
|
||||
$container->set(ProVM\Concept\Database\Query\Delete::class, function(Psr\Container\ContainerInterface $container) {
|
||||
return $container->get(ProVM\Database\Query\MySQL\Delete::class);
|
||||
});
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
QueryBuilder
|
||||
```
|
||||
include_once 'vendor/autoload.php';
|
||||
$qb = new QueryBuilder();
|
||||
|
||||
$query = $qb->select();
|
||||
$query = $qb->insert();
|
||||
$query = $qb->update();
|
||||
$query = $qb->delete();
|
||||
```
|
||||
|
||||
### Queries
|
||||
|
||||
Select
|
||||
```
|
||||
$query = $qb->select();
|
||||
$query = $qb->select(['id', 'column1']);
|
||||
|
||||
$query = $query->from('table');
|
||||
$query = $query->joins([['table2', 'table1.column = table2.column']]);
|
||||
$query = $query->where([['table2.column2', 10]]);
|
||||
```
|
Reference in New Issue
Block a user