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
|
|
|
function get_cpu_time() { |
52
|
|
|
$db = BoincDb::get(); |
53
|
|
|
$x = $db->get_double( |
54
|
|
|
"select sum(result.cpu_time) as total_cpu_time from workunit join result on workunit.id = result.workunitid where workunit.batch=$this->id", |
|
|
|
|
55
|
|
|
"total_cpu_time" |
56
|
|
|
); |
57
|
|
|
return $x; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
class BoincUserSubmit { |
62
|
|
|
static function enum($clause) { |
63
|
|
|
$db = BoincDb::get(); |
64
|
|
|
return $db->enum('user_submit', 'BoincUserSubmit', $clause); |
65
|
|
|
} |
66
|
|
|
static function insert($clause) { |
67
|
|
|
$db = BoincDb::get(); |
68
|
|
|
$ret = $db->insert('user_submit', $clause); |
69
|
|
|
if (!$ret) return false; |
70
|
|
|
return true; |
71
|
|
|
} |
72
|
|
|
static function lookup_userid($user_id) { |
73
|
|
|
$db = BoincDb::get(); |
74
|
|
|
return $db->lookup('user_submit', 'BoincUserSubmit', "user_id=$user_id"); |
75
|
|
|
} |
76
|
|
|
function update($clause) { |
77
|
|
|
$db = BoincDb::get(); |
78
|
|
|
return $db->update_aux('user_submit', "$clause where user_id=$this->user_id"); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
static function update_aux($clause) { |
81
|
|
|
$db = BoincDb::get(); |
82
|
|
|
return $db->update_aux('user_submit', $clause); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
static function delete_user($user_id) { |
86
|
|
|
$db = BoincDb::get(); |
87
|
|
|
return $db->delete_aux('user_submit', "user_id = $user_id"); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
class BoincUserSubmitApp { |
93
|
|
|
static function enum($clause) { |
94
|
|
|
$db = BoincDb::get(); |
95
|
|
|
return $db->enum('user_submit_app', 'BoincUserSubmitApp', $clause); |
96
|
|
|
} |
97
|
|
|
static function lookup($clause) { |
98
|
|
|
$db = BoincDb::get(); |
99
|
|
|
return $db->lookup('user_submit_app', 'BoincUserSubmitApp', $clause); |
100
|
|
|
} |
101
|
|
|
static function insert($clause) { |
102
|
|
|
$db = BoincDb::get(); |
103
|
|
|
$ret = $db->insert('user_submit_app', $clause); |
104
|
|
|
if (!$ret) return false; |
105
|
|
|
return true; |
106
|
|
|
} |
107
|
|
|
static function delete_user($user_id) { |
108
|
|
|
$db = BoincDb::get(); |
109
|
|
|
return $db->delete_aux('user_submit_app', "user_id=$user_id"); |
110
|
|
|
} |
111
|
|
|
function update($clause) { |
112
|
|
|
$db = BoincDb::get(); |
113
|
|
|
return $db->update_aux('user_submit_app', "$clause where user_id=$this->user_id and app_id=$this->app_id"); |
|
|
|
|
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
class BoincJobFile { |
118
|
|
|
static function insert($clause) { |
119
|
|
|
$db = BoincDb::get(); |
120
|
|
|
$ret = $db->insert('job_file', $clause); |
121
|
|
|
if (!$ret) return false; |
122
|
|
|
return $db->insert_id(); |
123
|
|
|
} |
124
|
|
|
static function lookup_name($name) { |
125
|
|
|
$db = BoincDb::get(); |
126
|
|
|
return $db->lookup('job_file', 'BoincJobFile', "name='$name'"); |
127
|
|
|
} |
128
|
|
|
function delete() { |
129
|
|
|
$db = BoincDb::get(); |
130
|
|
|
return $db->delete($this, 'job_file'); |
131
|
|
|
} |
132
|
|
|
function update($clause) { |
133
|
|
|
$db = BoincDb::get(); |
134
|
|
|
return $db->update($this, 'job_file', $clause); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
class BoincBatchFileAssoc { |
139
|
|
|
static function insert($clause) { |
140
|
|
|
$db = BoincDb::get(); |
141
|
|
|
$ret = $db->insert('batch_file_assoc', $clause); |
142
|
|
|
if (!$ret) return false; |
143
|
|
|
return true; |
144
|
|
|
} |
145
|
|
|
static function lookup($clause) { |
146
|
|
|
$db = BoincDb::get(); |
147
|
|
|
return $db->lookup('batch_file_assoc', 'BoincBatchFileAssoc', $clause); |
148
|
|
|
} |
149
|
|
|
function delete() { |
150
|
|
|
$db = BoincDb::get(); |
151
|
|
|
return $db->delete_aux('batch_file_assoc', |
152
|
|
|
"job_file_id=$this->job_file_id and batch_id=$this->batch_id" |
|
|
|
|
153
|
|
|
); |
154
|
|
|
} |
155
|
|
|
static function delete_batch($batch_id) { |
156
|
|
|
$db = BoincDb::get(); |
157
|
|
|
return $db->delete_aux('batch_file_assoc', |
158
|
|
|
"batch_id=$batch_id" |
159
|
|
|
); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
?> |
164
|
|
|
|