Skip to content

Instantly share code, notes, and snippets.

@ennjoy
Created May 26, 2020 16:54
Show Gist options
  • Save ennjoy/9e1d7d2c7b16aa593133f62ab27ea53d to your computer and use it in GitHub Desktop.
Save ennjoy/9e1d7d2c7b16aa593133f62ab27ea53d to your computer and use it in GitHub Desktop.
php.php
<?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