<?php

class JobController {
	public static function api_get_jobs($source) {
		$db = DB::getInstance();
		$q = $db->query("select * from job where source=:source order by queued", ["source" => $source]);
		
		$c = new Collection();

		while ($r = $db->nextRecord($q)) {
			$c->push($r);
		}
		return $c;
	}

	public static function api_delete_job($id) {
		$db = DB::getInstance();
		$q = $db->query("select * from job where id=:id", ["id" => $id]);
		$r = $db->nextRecord($q);
		$q = $db->query("delete from job where id=:id", ["id" => $id]);
		return JobController::api_get_jobs($r->source);
	}
}
