21 lines
522 B
PHP
21 lines
522 B
PHP
<?php
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$song_title = $_GET['song_title'] ?? '';
|
|
|
|
if (empty($song_title)) {
|
|
echo json_encode(['likes_count' => 0]);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$stmt = db()->prepare("SELECT likes_count FROM song_likes WHERE song_title = ?");
|
|
$stmt->execute([$song_title]);
|
|
$count = $stmt->fetchColumn();
|
|
echo json_encode(['likes_count' => (int)($count ?: 0)]);
|
|
} catch (Exception $e) {
|
|
echo json_encode(['error' => $e->getMessage()]);
|
|
}
|