-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.php
47 lines (39 loc) · 1.25 KB
/
tasks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
include_once './utility/mysql.php';
class tasks
{
public static function get_all($status = 0)
{
$ret = array();
$res = mysql::queryf('SELECT * FROM tasks WHERE status = %d', $status);
while ( $r = mysql_fetch_object($res) )
{
$r->seeds = unserialize($r->seeds);
$r->entry = unserialize($r->entry);
$ret []= $r;
}
return $ret;
}
public static function get_task($id)
{
$res = mysql::queryf('SELECT * FROM tasks WHERE id = %d', $id);
if ( $r = mysql_fetch_object($res) )
{
$r->seeds = unserialize($r->seeds);
$r->entry = unserialize($r->entry);
return $r;
}
return null;
}
public static function add_task( $volume_id, $seeds, $entry, $parent = 0, $status = 0 )
{
return mysql::insertf('INSERT INTO tasks VALUES( NULL, %d, %d, "%s", "%s", %d)',
$parent, $volume_id, serialize($seeds),
serialize($entry), $status);
}
public static function update_task_status( $id, $status )
{
return mysql::execf('UPDATE tasks SET status = %d WHERE id = %d',
$status, $id);
}
}