~ubuntu-branches/debian/sid/boinc/sid

« back to all changes in this revision

Viewing changes to html/inc/boinc_db.inc

  • Committer: Package Import Robot
  • Author(s): Steffen Moeller
  • Date: 2011-08-08 01:36:51 UTC
  • mfrom: (6.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20110808013651-m1hs3cltiveuteyn
Tags: 6.13.1+dfsg-2
* Bringing notify patch to unstable.
* Adjusted build dependency to libjpeg-dev (Closes: #641093)
* Further improvements on stripchart.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
// You should have received a copy of the GNU Lesser General Public License
17
17
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
 
require_once("../inc/db_conn.inc");
20
 
require_once("../inc/util_basic.inc");
 
19
$d = dirname(__FILE__);
 
20
require_once("$d/db_conn.inc");
 
21
require_once("$d/util_basic.inc");
21
22
 
22
23
class BoincDb extends DbConn {
23
24
    static $instance;
40
41
        }
41
42
        $instance = new DbConn();
42
43
        if ($readonly && $replica_host) {
 
44
            $x = parse_config($config, '<replica_db_user>');
 
45
            if ($x) $user = $x;
 
46
            $x = parse_config($config, '<replica_db_passwd>');
 
47
            if ($x) $passwd = $x;
 
48
            $x = parse_config($config, '<replica_db_name>');
 
49
            if ($x) $name = $x;
43
50
            $retval = $instance->init_conn($user, $passwd, $replica_host, $name);
44
51
            if ($retval) {
45
52
                self::$instance = $instance;
138
145
        $db->delete_aux('profile', "userid=$this->id");
139
146
        return $db->delete($this, 'user');
140
147
    }
 
148
    function sum($field) {
 
149
        $db = BoincDb::get();
 
150
        return $db->sum('user', $field);
 
151
    }
141
152
}
142
153
 
143
154
class BoincTeam {
215
226
        $db = BoincDb::get();
216
227
        return $db->enum('result', 'BoincResult', $clause);
217
228
    }
 
229
        static function enum_fields($fields, $where_clause, $order_clause) {
 
230
        $db = BoincDb::get();
 
231
                return $db->enum_fields('result', 'BoincResult', $fields, $where_clause, $order_clause);
 
232
        }
218
233
    static function update_aux($clause) {
219
234
        $db = BoincDb::get();
220
235
        return $db->update_aux('result', $clause);
234
249
        $db = BoincDb::get();
235
250
        return $db->lookup_id($id, 'workunit', 'BoincWorkunit');
236
251
    }
 
252
    static function lookup($clause) {
 
253
        $db = BoincDb::get();
 
254
        return $db->lookup('workunit', 'BoincWorkunit', $clause);
 
255
    }
237
256
    static function insert($clause) {
238
257
        $db = BoincDb::get();
239
258
        $ret = $db->insert('workunit', $clause);
269
288
        if (!$ret) return $ret;
270
289
        return $db->insert_id();
271
290
    }
 
291
    function update($clause) {
 
292
        $db = BoincDb::get();
 
293
        return $db->update($this, 'app', $clause);
 
294
    }
272
295
}
273
296
 
274
297
class BoincAppVersion {
284
307
        $db = BoincDb::get();
285
308
        return $db->lookup_id($id, 'app_version', 'BoincAppVersion');
286
309
    }
 
310
    static function insert($clause) {
 
311
        $db = BoincDb::get();
 
312
        $ret = $db->insert('app_version', $clause);
 
313
        if (!$ret) return $ret;
 
314
        return $db->insert_id();
 
315
    }
 
316
    function update($clause) {
 
317
        $db = BoincDb::get();
 
318
        return $db->update($this, 'app_version', $clause);
 
319
    }
287
320
}
288
321
 
289
322
class BoincProfile {
388
421
            "host_id=$host_id and app_version_id=$app_version_id"
389
422
        );
390
423
    }
 
424
    static function update_aux($clause) {
 
425
        $db = BoincDb::get();
 
426
        return $db->update_aux('host_app_version', $clause);
 
427
    }
391
428
}
392
429
 
393
430
?>