24 lines
579 B
PHP
24 lines
579 B
PHP
|
<?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)
|
||
|
);
|
||
|
|
||
|
return $result->fetchArray(SQLITE3_ASSOC);
|
||
|
}
|