Skip to content

Commit

Permalink
Get first / next video methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dphiffer committed Aug 25, 2015
1 parent 7589f3f commit 26fb311
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion flight-lines.php
Expand Up @@ -84,7 +84,32 @@ function get_pending_video() {
}

function get_next_video($after_id) {
return null;
if (empty($after_id)) {
return $this->get_first_video();
}
$query = $this->db->prepare("
SELECT *
FROM video
WHERE id > ?
ORDER BY created
LIMIT 1
");
$query->execute(array($after_id));
if ($query->rowCount() == 0) {
return $this->get_first_video();
} else {
return $query->fetch();
}
}

function get_first_video() {
$query = $this->db->query("
SELECT *
FROM video
ORDER BY created
LIMIT 1
");
return $query->fetch();
}

function api_index() {
Expand Down

0 comments on commit 26fb311

Please sign in to comment.