Skip to content

Commit

Permalink
* #hot-fix. readme custom sql
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Jun 4, 2017
1 parent 82a658d commit 7926a19
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ JSON API support turned on by default - see `Turn off JSON API support` section
* [Tree structures](#user-content-tree-structures)
* [Finite-state machine](#user-content-finite-state-machine)
* [Spell check](#user-content-spell-check)
* [Custom SQL](#user-content-custom-sql)
* [Conversions to RAML](#user-content-conversions-to-raml)

### Installation via composer:
Expand Down Expand Up @@ -962,6 +963,26 @@ You'll get the `meta` content back with filled array of failed checks in it:
}
}
```

### Custom SQL
If by any reason You need to use custom sql query - just define it in `Modules/V1/Config/config.php`:
```php
'custom_sql' => [
'article' => [
'enabled' => true,
'query' => 'SELECT title FROM article a INNER JOIN tag_article ta ON ta.article_id=a.id
WHERE ta.tag_id IN (
SELECT id FROM tag WHERE CHAR_LENGTH(title) > :tag_len
) ORDER BY a.id DESC',
'bindings' => [
'tag_len' => 5,
]
],
],
```
as U can see there are `query`, `bindings` (where has been passed a secured param-bound values) and `enabled` parameters for desired entity.
Custom sql query will be executed only for `index` API method,
so if U need ex. `delete` or `update` specific extra rows - call those methods with previously selected ids.

### Conversions to RAML

Expand Down

0 comments on commit 7926a19

Please sign in to comment.