2011-06-21 22:56:15 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2011 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// Tables related to job submission
|
|
|
|
|
2013-02-21 00:20:00 +00:00
|
|
|
require_once("../inc/common_defs.inc");
|
|
|
|
|
2011-06-21 22:56:15 +00:00
|
|
|
class BoincBatch {
|
|
|
|
static function lookup_id($id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'batch', 'BoincBatch');
|
|
|
|
}
|
2013-02-21 00:20:00 +00:00
|
|
|
static function lookup_name($name) {
|
|
|
|
$db = BoincDb::get();
|
2014-11-21 23:37:40 +00:00
|
|
|
$name = BoincDb::escape_string($name);
|
2013-02-21 00:20:00 +00:00
|
|
|
return $db->lookup('batch', 'BoincBatch', "name='$name'");
|
|
|
|
}
|
2011-06-21 22:56:15 +00:00
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('batch', 'BoincBatch', $clause);
|
|
|
|
}
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
$ret = $db->insert('batch', $clause);
|
|
|
|
if (!$ret) return $ret;
|
|
|
|
return $db->insert_id();
|
|
|
|
}
|
2011-07-27 06:20:48 +00:00
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update($this, 'batch', $clause);
|
|
|
|
}
|
2013-01-05 05:05:27 +00:00
|
|
|
static function update_aux($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update_aux('batch', $clause);
|
|
|
|
}
|
2015-06-29 22:28:51 +00:00
|
|
|
function get_cpu_time() {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
$x = $db->get_double(
|
|
|
|
"select sum(result.cpu_time) as total_cpu_time from workunit join result on workunit.id = result.workunitid where workunit.batch=$this->id",
|
|
|
|
"total_cpu_time"
|
|
|
|
);
|
|
|
|
return $x;
|
|
|
|
}
|
2011-06-21 22:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoincUserSubmit {
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('user_submit', 'BoincUserSubmit', $clause);
|
|
|
|
}
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
$ret = $db->insert('user_submit', $clause);
|
|
|
|
if (!$ret) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
static function lookup_userid($user_id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup('user_submit', 'BoincUserSubmit', "user_id=$user_id");
|
|
|
|
}
|
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update_aux('user_submit', "$clause where user_id=$this->user_id");
|
|
|
|
}
|
2013-01-05 05:05:27 +00:00
|
|
|
static function update_aux($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update_aux('user_submit', $clause);
|
|
|
|
}
|
2018-05-04 22:36:09 +00:00
|
|
|
|
|
|
|
static function delete_user($user_id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->delete_aux('user_submit', "user_id = $user_id");
|
|
|
|
}
|
|
|
|
|
2011-06-21 22:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoincUserSubmitApp {
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('user_submit_app', 'BoincUserSubmitApp', $clause);
|
|
|
|
}
|
|
|
|
static function lookup($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup('user_submit_app', 'BoincUserSubmitApp', $clause);
|
|
|
|
}
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
$ret = $db->insert('user_submit_app', $clause);
|
|
|
|
if (!$ret) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
static function delete_user($user_id) {
|
|
|
|
$db = BoincDb::get();
|
2016-07-25 05:55:33 +00:00
|
|
|
return $db->delete_aux('user_submit_app', "user_id=$user_id");
|
2011-06-21 22:56:15 +00:00
|
|
|
}
|
2012-05-29 05:48:25 +00:00
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
2016-07-25 05:55:33 +00:00
|
|
|
return $db->update_aux('user_submit_app', "$clause where user_id=$this->user_id and app_id=$this->app_id");
|
2012-05-29 05:48:25 +00:00
|
|
|
}
|
2011-06-21 22:56:15 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 03:12:08 +00:00
|
|
|
class BoincJobFile {
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
$ret = $db->insert('job_file', $clause);
|
|
|
|
if (!$ret) return false;
|
2017-01-26 00:17:42 +00:00
|
|
|
return $db->insert_id();
|
2012-11-26 03:12:08 +00:00
|
|
|
}
|
2017-02-17 21:51:30 +00:00
|
|
|
static function lookup_name($name) {
|
2012-11-26 03:12:08 +00:00
|
|
|
$db = BoincDb::get();
|
2017-02-17 21:51:30 +00:00
|
|
|
return $db->lookup('job_file', 'BoincJobFile', "name='$name'");
|
2012-11-26 03:12:08 +00:00
|
|
|
}
|
|
|
|
function delete() {
|
|
|
|
$db = BoincDb::get();
|
2017-02-21 17:30:49 +00:00
|
|
|
return $db->delete($this, 'job_file');
|
2012-11-26 03:12:08 +00:00
|
|
|
}
|
2012-11-26 20:49:31 +00:00
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update($this, 'job_file', $clause);
|
|
|
|
}
|
2012-11-26 03:12:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 07:51:02 +00:00
|
|
|
class BoincBatchFileAssoc {
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
$ret = $db->insert('batch_file_assoc', $clause);
|
|
|
|
if (!$ret) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
static function lookup($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup('batch_file_assoc', 'BoincBatchFileAssoc', $clause);
|
|
|
|
}
|
|
|
|
function delete() {
|
|
|
|
$db = BoincDb::get();
|
2016-07-25 05:55:33 +00:00
|
|
|
return $db->delete_aux('batch_file_assoc',
|
2013-05-29 06:14:17 +00:00
|
|
|
"job_file_id=$this->job_file_id and batch_id=$this->batch_id"
|
|
|
|
);
|
2013-01-23 07:51:02 +00:00
|
|
|
}
|
2013-09-17 20:35:55 +00:00
|
|
|
static function delete_batch($batch_id) {
|
|
|
|
$db = BoincDb::get();
|
2016-07-25 05:55:33 +00:00
|
|
|
return $db->delete_aux('batch_file_assoc',
|
2013-09-17 20:35:55 +00:00
|
|
|
"batch_id=$batch_id"
|
|
|
|
);
|
|
|
|
}
|
2013-01-23 07:51:02 +00:00
|
|
|
}
|
|
|
|
|
2011-06-21 22:56:15 +00:00
|
|
|
?>
|