My query:
SELECT *
FROM outlets
INNER JOIN users ON outlets.owner=users.id;
The result is an array in which the indexes from one table match those of another table. Is it possible to somehow make such a request that owner = array, and there is already a structure
Result:
Array ( [id] => 1 [owner] => 1 [name] => Рома [email] => admin => admin [password] => admin [role] => 1 [photo] => [permissions] => {"menu": {"menu.shop": 1, "menu.users": 1, "menu.stocks": 1, "menu.clients": 1, "menu.finances": 1, "menu.partners": 1, "menu.products": 1, "menu.purchase": 1, "menu.dashboard": 1}} [status] => 1 )
2
Answers
To return a result as an associative array use
If I understood correctly. You want to have an owner value containing data of the user (but not having data on the same level).
Option 1: By SQL you can do 2 separate queries and join results manually by PHP. But then you may have performance penalties.
Option 2: As a recommendation, if you need such a payload, just reformat your array as desired manually like this:
Hope it helps.