8000 V2.2 by muhammetsafak · Pull Request #20 · InitPHP/Database · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

V2.2 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 11, 2023
Merged

V2.2 #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,24 @@ foreach ($results as $row) {
}
```

#### Working With A Different Connection

This library was developed with the thought that you would work with a single database and connection, but I know that in some projects you work with more than one connection and database.

If you want to work with a different non-global connection, use the `connect()` method.

```php
use \InitPHP\Database\Facade\DB;

DB::connect([
'dsn' => 'mysql:host=localhost;port=3306;dbname=test;charset=utf8mb4',
'username' => 'root',
'password' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
]);
```

### Model and Entity

Model and Entity; are two common concepts used in database abstraction. To explain these two concepts in the roughest way;
Expand Down Expand Up @@ -448,6 +466,10 @@ class PostEntity extends \InitPHP\Database\Entity
}
```

## Developement Tools

Below I have mentioned some developer tools that you can use during and after development.

### Logger

```php
Expand Down Expand Up @@ -525,6 +547,34 @@ DB::createImmutable([
]);
```

### Profiler Mode

Profiler mode is a developer tool available in v2.2 and above. It is a feature that allows you to see the executed queries along with their execution times.

```php
use InitPHP\Database\Facade\DB;

DB::enableQueryProfiler();

DB::table('users')->where('name', 'John')->get();

var_dump(DB::getProfilerQueries());

/**
* The output of the above example looks like this;
* [
* [
* 'query' => 'SELECT * FROM users WHERE name = :name',
* 'time' => '0.00064',
* 'args' => [
* ':name' => 'John',
* ]
* ]
* ]
*
*/
```

## To Do

- [ ] A more detailed documentation will be prepared.
Expand Down
Loading
0