2024-09-01 18:54:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function prepare_and_execute($conn, $stmt_string, $parameters) {
|
|
|
|
$stmt = $conn->prepare($stmt_string);
|
|
|
|
|
|
|
|
foreach ($parameters as $k => $v) {
|
|
|
|
$stmt->bindValue($k, $v);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $stmt->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
function sql_fetch_actor($conn, string $preferred_username) {
|
|
|
|
$object_id = 'https://' . HOSTAS_DOMAIN . "/api/v1/actor/$preferred_username";
|
|
|
|
$result = prepare_and_execute($conn,
|
|
|
|
"select * from actor
|
|
|
|
join object on actor.objectId = object.id
|
|
|
|
where object.id = :object_id",
|
|
|
|
array(':object_id' => $object_id)
|
|
|
|
);
|
|
|
|
|
2024-09-01 21:54:35 +00:00
|
|
|
// fetchArray returns false when there's no array; we're rather have it be
|
|
|
|
// explicitly null
|
|
|
|
$actor = $result->fetchArray(SQLITE3_ASSOC);
|
|
|
|
return $actor !== false ? $actor : null;
|
2024-09-01 18:54:41 +00:00
|
|
|
}
|