Skip to content

Commit

Permalink
update READMD.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Link1515 committed Mar 27, 2024
1 parent cdf338f commit 1e672d3
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,20 @@ DB::PDO(?string $id): PDO;
The BaseORM class has some common methods for creating, querying, updating and deleting. In simple applications, stataic methods can be called directly for specified table operation.

```php
/**
* options:
* {
* page: number|string
* perPage: number|string
* orderBy: string|array
* }
*
* ex (default value):
* [
* 'page' => 1,
* 'perPage' => 20,
* 'orderBy' => 'id ASC'
* ]
*/
// options
// - page (int)
// - perPage (int)
// - orderBy (string|array)
// default value
// $options = [
// 'page' => 1,
// 'perPage' => 20,
// 'orderBy' => 'id ASC'
// ]
BaseORM::getAllForTable(string $tableName, ?array $columns = null, ?array $options): array;

BaseORM::getCountForTable(string $tableName): int;

BaseORM::getByIdForTable(string $tableName, int|string $id, ?array $columns = null): array|null;

BaseORM::createForTable(string $tableName, array $data): bool;
Expand Down Expand Up @@ -107,14 +104,16 @@ BaseORM::getAllForTable('users', ['name', 'phone']);
BaseORM::getAllForTable('users', ['name' => 'username', 'phone' => 'cellphone']);
// query all and set pagination
BaseORM::getAllForTable('users', null, [
'page' => 1,
'page' => 2,
'perPage' => 30
]);
// query all and order by
BaseORM::getAllForTable('users', null, [
'orderBy' => ['department_id DESC', 'id ASC'],
]);

BaseORM::getCountForTable('users');

// query by id
BaseORM::getByIdForTable('users', 1);
// query by id and specified field
Expand All @@ -141,6 +140,8 @@ In this case, you need to get the instance by getInstance() method and operate o
```php
getAll(?array $columns = null, ?array $options): array;

getCount(): int;

getById(int|string $id, ?int $columns = null): array|null;

create(array $data): bool;
Expand Down

0 comments on commit 1e672d3

Please sign in to comment.