remove db prefix

This commit is contained in:
Dennis Eichhorn 2020-03-12 18:02:43 +01:00
parent 9680610c02
commit 450371d0eb
2 changed files with 11 additions and 23 deletions

View File

@ -14,7 +14,6 @@ $con = new MysqlConnection([
'login' => 'root', /* db login name */ 'login' => 'root', /* db login name */
'password' => 'root', /* db login password */ 'password' => 'root', /* db login password */
'database' => 'oms', /* db name */ 'database' => 'oms', /* db name */
'prefix' => 'oms_', /* db table prefix */
]); ]);
``` ```
@ -32,7 +31,6 @@ $con = ConnectionFactory::create([
'login' => 'root', 'login' => 'root',
'password' => 'root', 'password' => 'root',
'database' => 'oms', 'database' => 'oms',
'prefix' => 'oms_',
]); ]);
``` ```
@ -62,7 +60,6 @@ $dbPool->create('read',
'login' => 'root', 'login' => 'root',
'password' => 'root', 'password' => 'root',
'database' => 'oms', 'database' => 'oms',
'prefix' => 'oms_',
] ]
); );
``` ```

View File

@ -14,34 +14,25 @@ The database query builder provides a uniform way to write default database quer
The query builder is used for regular CRUD operations on the database. The query builder is used for regular CRUD operations on the database.
#### Prefix
Projects often use a prefix for all of the tables. For this project the default prefix is `oms_`.
```php
$query = new Builder();
$query->prefix('oms_');
```
#### Select, Insert, Update, Delete #### Select, Insert, Update, Delete
Both `select` and `insert` expect the column names as parameter. The `where`, `from` and `into` clause can be necessary depending on the type of operation like a normal sql query. Both `select` and `insert` expect the column names as parameter. The `where`, `from` and `into` clause can be necessary depending on the type of operation like a normal sql query.
```php ```php
$query->prefix(...)->select('columnA', 'columnB')->from('table')->where(...); $query->select('columnA', 'columnB')->from('table')->where(...);
$query->prefix(...)->insert('columnA', 'columnB')->values('a', 'b')->into('table'); $query->insert('columnA', 'columnB')->values('a', 'b')->into('table');
``` ```
The `update` expects the table name which should be updated and then the `set` function to define the columns and new values. The `update` expects the table name which should be updated and then the `set` function to define the columns and new values.
```php ```php
$query->prefix(...)->update('table')->set(['columnA' => 'a'])->set(['columnB' => 'b'])->where(...); $query->update('table')->set(['columnA' => 'a'])->set(['columnB' => 'b'])->where(...);
``` ```
The `delete` function only expects the `from` and `where` clause to identify the to delete columns in a table. The `delete` function only expects the `from` and `where` clause to identify the to delete columns in a table.
```php ```php
$query->prefix(...)->delete()->from('table')->where(...); $query->delete()->from('table')->where(...);
``` ```
##### Random ##### Random
@ -51,8 +42,8 @@ $query->prefix(...)->delete()->from('table')->where(...);
The `from` part of a query accepts `string`, `array`, `\Closure`, `From`, `Builder` as parameter. The `from` part of a query accepts `string`, `array`, `\Closure`, `From`, `Builder` as parameter.
```php ```php
$query->prefix(...)->select(...)->from('table'); $query->select(...)->from('table');
$query->prefix(...)->select(...)->from('tableA', 'tableB'); $query->select(...)->from('tableA', 'tableB');
``` ```
#### Into #### Into
@ -64,7 +55,7 @@ The `into` part of a query accepts `string`, `array`, `\Closure`, `Into`, `Build
The basic `where` clause expects a column, operator, value and boolean concatenater which is used to concatenate multiple where clauses. The basic `where` clause expects a column, operator, value and boolean concatenater which is used to concatenate multiple where clauses.
```php ```php
$query->prefix(...)->select(...)->from(...)->where('columnA', '=', 123)->where('columnB', '=', 'abc', 'or'); $query->select(...)->from(...)->where('columnA', '=', 123)->where('columnB', '=', 'abc', 'or');
``` ```
For easier use additional `where` clauses are defined such as: For easier use additional `where` clauses are defined such as:
@ -80,7 +71,7 @@ For easier use additional `where` clauses are defined such as:
The `limit` expects an integer. The `limit` expects an integer.
```php ```php
$query->prefix(...)->select(...)->from(...)->where(...)->limit(3); $query->select(...)->from(...)->where(...)->limit(3);
``` ```
#### Offset #### Offset
@ -88,7 +79,7 @@ $query->prefix(...)->select(...)->from(...)->where(...)->limit(3);
The `offset` expects an integer. The `offset` expects an integer.
```php ```php
$query->prefix(...)->select(...)->from(...)->where(...)->offset(3); $query->select(...)->from(...)->where(...)->offset(3);
``` ```
#### Order #### Order
@ -96,7 +87,7 @@ $query->prefix(...)->select(...)->from(...)->where(...)->offset(3);
The ordering is performed by `orderBy`. The ordering is performed by `orderBy`.
```php ```php
$query->prefix(...)->select(...)->from(...)->where(...)->orderBy('columnA', 'DESC'); $query->select(...)->from(...)->where(...)->orderBy('columnA', 'DESC');
``` ```
The `newest` and `oldest` operation are a small wrapper which automatically order by `DESC` and `ASC` respectively. The `newest` and `oldest` operation are a small wrapper which automatically order by `DESC` and `ASC` respectively.
@ -106,7 +97,7 @@ The `newest` and `oldest` operation are a small wrapper which automatically orde
Grouping of columns can be achieved through `groupBy`. Grouping of columns can be achieved through `groupBy`.
```php ```php
$query->prefix(...)->select(...)->from(...)->where(...)->groupBy('columnA', 'columnB'); $query->select(...)->from(...)->where(...)->groupBy('columnA', 'columnB');
``` ```
#### Join #### Join