mirror of
https://codeberg.org/vlw/php-libinnodb-fk.git
synced 2025-09-13 16:13:41 +02:00
fix(doc): namespace README
This commit is contained in:
parent
0db93592d5
commit
2ceaa1358b
1 changed files with 24 additions and 9 deletions
23
README.md
23
README.md
|
@ -6,10 +6,10 @@ This library retrievies and optionally resolves foreign keys in a MySQL/MariaDB
|
|||
|
||||
## Install with composer
|
||||
```
|
||||
composer require victorwesterlund/libinnodb-fk
|
||||
composer require victorwesterlund/innodb-fk
|
||||
```
|
||||
```php
|
||||
use victorwesterlund\ForeignKeys\ForeignKeys
|
||||
use victorwesterlund\ForeignKeys
|
||||
```
|
||||
|
||||
# Example / Documentation
|
||||
|
@ -25,7 +25,7 @@ Remember to pass the database name where InnoDB foreign keys are stored to the 4
|
|||
## Initialize `ForeignKeys`
|
||||
|
||||
```php
|
||||
use victorwesterlund\ForeignKeys\ForeignKeys
|
||||
use victorwesterlund\ForeignKeys
|
||||
|
||||
$fk = new ForeignKeys($host, $user, $pass, ForeignKeys::DATABASE_NAME);
|
||||
```
|
||||
|
@ -55,19 +55,34 @@ Retrieve rows from your database and pass them to `resolve_all()` as an array of
|
|||
|
||||
```php
|
||||
$rows = [
|
||||
[
|
||||
"id" => 1,
|
||||
"fk" => 2
|
||||
],
|
||||
[
|
||||
"id" => 2,
|
||||
"fk" => 1
|
||||
]
|
||||
];
|
||||
|
||||
$rows = $fk->for("test", "bar")->resolve_all($rows);
|
||||
```
|
||||
```php
|
||||
// $rows will become
|
||||
[
|
||||
[
|
||||
"id" => 1,
|
||||
"fk" => [
|
||||
"id" => 2,
|
||||
"value" => "hello world"
|
||||
"value" => "lorem ipsum dolor sit amet"
|
||||
]
|
||||
],
|
||||
[
|
||||
"id" => 2,
|
||||
"fk" => [
|
||||
"id" => 1,
|
||||
"value" => "consectetur adipiscing elit"
|
||||
]
|
||||
]
|
||||
]
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue