function getModels(int $page = 1, int $perPage = 120): array { $db = new PDO('sqlite:' . __DIR__ . '/../cache/models.sqlite'); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $offset = ($page - 1) * $perPage; $stmt = $db->prepare(' SELECT * FROM models ORDER BY displayName LIMIT :l OFFSET :o '); $stmt->bindValue(':l', $perPage, PDO::PARAM_INT); $stmt->bindValue(':o', $offset, PDO::PARAM_INT); $stmt->execute(); $rows = $stmt->fetchAll(); return array_map(function($r) { // pull the JSON‐wrapped details back into an array $details = json_decode($r['detailsJson'], true); // re-attach the columns you need $details['uniqueModelId'] = $r['uniqueModelId']; $details['displayName'] = $r['displayName']; $details['slug'] = $r['slug']; $details['fullSlug'] = $r['fullSlug']; // **this** is the URL you stored $details['profilePictureUrl'] = [ 'size1024x768' => $r['img1024'] ]; return $details; }, $rows); }