mirror of
https://codeberg.org/vlw/php-libinnodb-fk.git
synced 2025-09-13 16:13:41 +02:00
fix: namespace issue (#3)
* fix: namespace issue * fix(doc): namespace README
This commit is contained in:
parent
6b8dcfd040
commit
ffea024f16
3 changed files with 26 additions and 11 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
|
## Install with composer
|
||||||
```
|
```
|
||||||
composer require victorwesterlund/libinnodb-fk
|
composer require victorwesterlund/innodb-fk
|
||||||
```
|
```
|
||||||
```php
|
```php
|
||||||
use victorwesterlund\ForeignKeys\ForeignKeys
|
use victorwesterlund\ForeignKeys
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example / Documentation
|
# Example / Documentation
|
||||||
|
@ -25,7 +25,7 @@ Remember to pass the database name where InnoDB foreign keys are stored to the 4
|
||||||
## Initialize `ForeignKeys`
|
## Initialize `ForeignKeys`
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use victorwesterlund\ForeignKeys\ForeignKeys
|
use victorwesterlund\ForeignKeys
|
||||||
|
|
||||||
$fk = new ForeignKeys($host, $user, $pass, ForeignKeys::DATABASE_NAME);
|
$fk = new ForeignKeys($host, $user, $pass, ForeignKeys::DATABASE_NAME);
|
||||||
```
|
```
|
||||||
|
@ -55,8 +55,14 @@ Retrieve rows from your database and pass them to `resolve_all()` as an array of
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$rows = [
|
$rows = [
|
||||||
|
[
|
||||||
"id" => 1,
|
"id" => 1,
|
||||||
"fk" => 2
|
"fk" => 2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"id" => 2,
|
||||||
|
"fk" => 1
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$rows = $fk->for("test", "bar")->resolve_all($rows);
|
$rows = $fk->for("test", "bar")->resolve_all($rows);
|
||||||
|
@ -64,10 +70,19 @@ $rows = $fk->for("test", "bar")->resolve_all($rows);
|
||||||
```php
|
```php
|
||||||
// $rows will become
|
// $rows will become
|
||||||
[
|
[
|
||||||
|
[
|
||||||
"id" => 1,
|
"id" => 1,
|
||||||
"fk" => [
|
"fk" => [
|
||||||
"id" => 2,
|
"id" => 2,
|
||||||
"value" => "hello world"
|
"value" => "lorem ipsum dolor sit amet"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"id" => 2,
|
||||||
|
"fk" => [
|
||||||
|
"id" => 1,
|
||||||
|
"value" => "consectetur adipiscing elit"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"ForeignKeys\\": "src/"
|
"victorwesterlund\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace victorwesterlund\ForeignKeys;
|
namespace victorwesterlund;
|
||||||
|
|
||||||
use \victorwesterlund\xEnum;
|
use \victorwesterlund\xEnum;
|
||||||
use \libmysqldriver\MySQL as MySQLDriver;
|
use \libmysqldriver\MySQL as MySQLDriver;
|
||||||
|
|
Loading…
Add table
Reference in a new issue