Created
May 26, 2020 16:54
-
-
Save ennjoy/9e1d7d2c7b16aa593133f62ab27ea53d to your computer and use it in GitHub Desktop.
php.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_wall(int $owner_id): array | |
{ | |
$db = DbMysqlProvider::getConnection(); | |
$db->where('owner_id', $owner_id); | |
$db->where('active', 1); | |
$db->orderBy('date', 'DESC'); | |
$raw_wall = $db->get('wall'); | |
$raw_wall = array_combine( | |
array_map(function ($item) { return $item['id']; }, $raw_wall), | |
$raw_wall | |
); | |
$audios = $db->rawQuery(' | |
SELECT wall_audios.wall, wall_audios.audio AS audio | |
FROM wall_audios | |
JOIN wall ON wall.id = wall_audios.wall | |
WHERE wall_audios.wall IN (?)', [7]); | |
foreach ($raw_wall as $wall) { | |
$wall['audio'] = $audios; | |
} | |
var_dump($wall); | |
return $wall ?? []; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment