1
|
|
|
<?php |
2
|
|
|
// This file is part of BOINC. |
3
|
|
|
// http://boinc.berkeley.edu |
4
|
|
|
// Copyright (C) 2011 University of California |
5
|
|
|
// |
6
|
|
|
// BOINC is free software; you can redistribute it and/or modify it |
7
|
|
|
// under the terms of the GNU Lesser General Public License |
8
|
|
|
// as published by the Free Software Foundation, |
9
|
|
|
// either version 3 of the License, or (at your option) any later version. |
10
|
|
|
// |
11
|
|
|
// BOINC is distributed in the hope that it will be useful, |
12
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
14
|
|
|
// See the GNU Lesser General Public License for more details. |
15
|
|
|
// |
16
|
|
|
// You should have received a copy of the GNU Lesser General Public License |
17
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
|
19
|
|
|
// Tables related to job submission |
20
|
|
|
|
21
|
|
|
require_once("../inc/common_defs.inc"); |
22
|
|
|
|
23
|
|
|
class BoincBatch { |
24
|
|
|
static function lookup_id($id) { |
25
|
|
|
$db = BoincDb::get(); |
26
|
|
|
return $db->lookup_id($id, 'batch', 'BoincBatch'); |
27
|
|
|
} |
28
|
|
|
static function lookup_name($name) { |
29
|
|
|
$db = BoincDb::get(); |
30
|
|
|
$name = BoincDb::escape_string($name); |
31
|
|
|
return $db->lookup('batch', 'BoincBatch', "name='$name'"); |
32
|
|
|
} |
33
|
|
|
static function enum($clause) { |
34
|
|
|
$db = BoincDb::get(); |
35
|
|
|
return $db->enum('batch', 'BoincBatch', $clause); |
36
|
|
|
} |
37
|
|
|
static function insert($clause) { |
38
|
|
|
$db = BoincDb::get(); |
39
|
|
|
$ret = $db->insert('batch', $clause); |
40
|
|
|
if (!$ret) return $ret; |
41
|
|
|
return $db->insert_id(); |
42
|
|
|
} |
43
|
|
|
function update($clause) { |
44
|
|
|
$db = BoincDb::get(); |
45
|
|
|
return $db->update($this, 'batch', $clause); |
46
|
|
|
} |
47
|
|
|
static function update_aux($clause) { |
48
|
|
|
$db = BoincDb::get(); |
49
|
|
|
return $db->update_aux('batch', $clause); |
50
|
|
|
} |
51
|
|
|
static function delete_batch($id) { |
52
|
|
|
$db = BoincDb::get(); |
53
|
|
|
$id = intval($id); |
54
|
|
|
return $db->delete_aux('batch', "id=$id"); |
55
|
|
|
} |
56
|
|
|
function get_cpu_time() { |
57
|
|
|
$db = BoincDb::get(); |
58
|
|
|
$x = $db->get_double( |
59
|
|
|
"select sum(result.cpu_time) as total_cpu_time from workunit join result on workunit.id = result.workunitid where workunit.batch=$this->id", |
|
|
|
|
60
|
|
|
"total_cpu_time" |
61
|
|
|
); |
62
|
|
|
return $x; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
class BoincUserSubmit { |
67
|
|
|
static function enum($clause) { |
68
|
|
|
$db = BoincDb::get(); |
69
|
|
|
return $db->enum('user_submit', 'BoincUserSubmit', $clause); |
70
|
|
|
} |
71
|
|
|
static function insert($clause) { |
72
|
|
|
$db = BoincDb::get(); |
73
|
|
|
$ret = $db->insert('user_submit', $clause); |
74
|
|
|
if (!$ret) return false; |
75
|
|
|
return true; |
76
|
|
|
} |
77
|
|
|
static function lookup_userid($user_id) { |
78
|
|
|
$db = BoincDb::get(); |
79
|
|
|
return $db->lookup('user_submit', 'BoincUserSubmit', "user_id=$user_id"); |
80
|
|
|
} |
81
|
|
|
function update($clause) { |
82
|
|
|
$db = BoincDb::get(); |
83
|
|
|
return $db->update_aux('user_submit', "$clause where user_id=$this->user_id"); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
static function update_aux($clause) { |
86
|
|
|
$db = BoincDb::get(); |
87
|
|
|
return $db->update_aux('user_submit', $clause); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
static function delete_user($user_id) { |
91
|
|
|
$db = BoincDb::get(); |
92
|
|
|
return $db->delete_aux('user_submit', "user_id = $user_id"); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
class BoincUserSubmitApp { |
98
|
|
|
static function enum($clause) { |
99
|
|
|
$db = BoincDb::get(); |
100
|
|
|
return $db->enum('user_submit_app', 'BoincUserSubmitApp', $clause); |
101
|
|
|
} |
102
|
|
|
static function lookup($clause) { |
103
|
|
|
$db = BoincDb::get(); |
104
|
|
|
return $db->lookup('user_submit_app', 'BoincUserSubmitApp', $clause); |
105
|
|
|
} |
106
|
|
|
static function insert($clause) { |
107
|
|
|
$db = BoincDb::get(); |
108
|
|
|
$ret = $db->insert('user_submit_app', $clause); |
109
|
|
|
if (!$ret) return false; |
110
|
|
|
return true; |
111
|
|
|
} |
112
|
|
|
static function delete_user($user_id) { |
113
|
|
|
$db = BoincDb::get(); |
114
|
|
|
return $db->delete_aux('user_submit_app', "user_id=$user_id"); |
115
|
|
|
} |
116
|
|
|
function update($clause) { |
117
|
|
|
$db = BoincDb::get(); |
118
|
|
|
return $db->update_aux('user_submit_app', "$clause where user_id=$this->user_id and app_id=$this->app_id"); |
|
|
|
|
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
class BoincJobFile { |
123
|
|
|
static function insert($clause) { |
124
|
|
|
$db = BoincDb::get(); |
125
|
|
|
$ret = $db->insert('job_file', $clause); |
126
|
|
|
if (!$ret) return false; |
127
|
|
|
return $db->insert_id(); |
128
|
|
|
} |
129
|
|
|
static function lookup_name($name) { |
130
|
|
|
$db = BoincDb::get(); |
131
|
|
|
return $db->lookup('job_file', 'BoincJobFile', "name='$name'"); |
132
|
|
|
} |
133
|
|
|
function delete() { |
134
|
|
|
$db = BoincDb::get(); |
135
|
|
|
return $db->delete($this, 'job_file'); |
136
|
|
|
} |
137
|
|
|
function update($clause) { |
138
|
|
|
$db = BoincDb::get(); |
139
|
|
|
return $db->update($this, 'job_file', $clause); |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
class BoincBatchFileAssoc { |
144
|
|
|
static function insert($clause) { |
145
|
|
|
$db = BoincDb::get(); |
146
|
|
|
$ret = $db->insert('batch_file_assoc', $clause); |
147
|
|
|
if (!$ret) return false; |
148
|
|
|
return true; |
149
|
|
|
} |
150
|
|
|
static function lookup($clause) { |
151
|
|
|
$db = BoincDb::get(); |
152
|
|
|
return $db->lookup('batch_file_assoc', 'BoincBatchFileAssoc', $clause); |
153
|
|
|
} |
154
|
|
|
function delete() { |
155
|
|
|
$db = BoincDb::get(); |
156
|
|
|
return $db->delete_aux('batch_file_assoc', |
157
|
|
|
"job_file_id=$this->job_file_id and batch_id=$this->batch_id" |
|
|
|
|
158
|
|
|
); |
159
|
|
|
} |
160
|
|
|
static function delete_batch($batch_id) { |
161
|
|
|
$db = BoincDb::get(); |
162
|
|
|
return $db->delete_aux('batch_file_assoc', |
163
|
|
|
"batch_id=$batch_id" |
164
|
|
|
); |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
?> |
169
|
|
|
|