mirror of
https://codeberg.org/vlw/php-libinnodb-fk.git
synced 2025-09-14 00:23:41 +02:00
Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
ffea024f16 | |||
6b8dcfd040 |
4 changed files with 33 additions and 23 deletions
33
README.md
33
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,
|
[
|
||||||
"fk" => 2
|
"id" => 1,
|
||||||
|
"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,
|
[
|
||||||
"fk" => [
|
"id" => 1,
|
||||||
"id" => 2,
|
"fk" => [
|
||||||
"value" => "hello world"
|
"id" => 2,
|
||||||
|
"value" => "lorem ipsum dolor sit amet"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"id" => 2,
|
||||||
|
"fk" => [
|
||||||
|
"id" => 1,
|
||||||
|
"value" => "consectetur adipiscing elit"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "victorwesterlund/innodb-fk",
|
"name": "victorwesterlund/libinnodb-fk",
|
||||||
"description": "Retrievie and optionally resolves foreign keys in a MySQL/MariaDB InnoDB database",
|
"description": "Retrievie and optionally resolves foreign keys in a MySQL/MariaDB InnoDB database",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
|
@ -12,11 +12,11 @@
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"ForeignKeys\\": "src/"
|
"victorwesterlund\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"victorwesterlund/libmysqldriver": "dev-master",
|
"victorwesterlund/libmysqldriver": "^3.0",
|
||||||
"victorwesterlund/xenum": "dev-master"
|
"victorwesterlund/xenum": "^1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
composer.lock
generated
13
composer.lock
generated
|
@ -4,11 +4,11 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "eaa9235118e1c92aa3ba7d567dd02528",
|
"content-hash": "3d45c83fad219dba6e2178c379070b39",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "victorwesterlund/libmysqldriver",
|
"name": "victorwesterlund/libmysqldriver",
|
||||||
"version": "dev-master",
|
"version": "3.1.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/VictorWesterlund/php-libmysqldriver.git",
|
"url": "https://github.com/VictorWesterlund/php-libmysqldriver.git",
|
||||||
|
@ -20,7 +20,6 @@
|
||||||
"reference": "f9ec9064147e2f78d14800e755ee54df25714d96",
|
"reference": "f9ec9064147e2f78d14800e755ee54df25714d96",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -46,7 +45,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "victorwesterlund/xenum",
|
"name": "victorwesterlund/xenum",
|
||||||
"version": "dev-master",
|
"version": "1.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/VictorWesterlund/php-xenum.git",
|
"url": "https://github.com/VictorWesterlund/php-xenum.git",
|
||||||
|
@ -58,7 +57,6 @@
|
||||||
"reference": "99b784841ee5b69fdfcc4c466ef54f3af4ea4a85",
|
"reference": "99b784841ee5b69fdfcc4c466ef54f3af4ea4a85",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -86,10 +84,7 @@
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": {
|
"stability-flags": [],
|
||||||
"victorwesterlund/libmysqldriver": 20,
|
|
||||||
"victorwesterlund/xenum": 20
|
|
||||||
},
|
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
|
|
|
@ -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