prepare( "INSERT INTO doc_storage (idhome, entity_type, owner_id, document_id, title, filename, expirystatus, expirydate, note, created_at, updated_at) VALUES (NULL, 'person', ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())" ); $stmt->execute([$ownerId, $documentId, $title ?: null, $filename, $expiryStatus, $expiry ?: null, $note ?: null]); $id = (int) $pdo->lastInsertId(); $row = $pdo->prepare('SELECT * FROM doc_storage WHERE id = ?'); $row->execute([$id]); json_data(present_file($row->fetch()), 201);