prepare(" select * from actor join object on actor.objectId = object.id where preferredUsername = :preferred_username limit 1; "); $actor_query->bindValue(':preferred_username', $preferred_username); $actor_result = $actor_query->execute(); $actor = $actor_result->fetchArray(); if(!$actor) { echo "No actor by the preferred username $preferred_username. Exiting" . PHP_EOL; $conn->close(); exit(1); } $content = readline('Content: '); $note_result = prepare_and_execute($conn, "insert into object(id, type, published, attributedTo, content) values (:id, :type, :published, :attributedTo, :content);", array( ':id' => $note_id, ':type' => 'Note', ':published' => $published, ':attributedTo' => $actor['id'], ':content' => $content ) ); if (!$note_result) { echo 'Failed to create note. Exiting' . PHP_EOL; $conn->close(); exit(); } echo "Note created at $note_id" . PHP_EOL; $activity_object_result = prepare_and_execute($conn, "insert into object(id, type, published) values(:id, :type, :published);", array( ':id' => $activity_id, ':type' => 'Create', ':published' => $published, ) ); if (!$activity_object_result) { echo 'Failed to create the activity\'s object. Exiting' . PHP_EOL; $conn->close(); exit(); } echo "Object created for Create activity at $activity_id" . PHP_EOL; $activity_result = prepare_and_execute($conn, "insert into activity(objectId, actor, object) values(:objectId, :actor, :object);", array( ':objectId' => $activity_id, ':actor' => $actor['id'], ':object' => $note_id, ) ); if (!$activity_result) { echo 'Failed to create the activity record. Exiting' . PHP_EOL; $conn->close(); exit(); } echo "Successfully created activity." . PHP_EOL; $conn->close();