ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilADTActiveRecord.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
14{
15 protected $properties; // [ilADTGroupDBBridge]
16
23 public function __construct(ilADTGroupDBBridge $a_properties)
24 {
25 $this->properties = $a_properties;
26 }
27
33 public function read()
34 {
35 global $ilDB;
36
37 // reset all group elements
38 $this->properties->getADT()->reset();
39
40 $sql = "SELECT * FROM " . $this->properties->getTable() .
41 " WHERE " . $this->properties->buildPrimaryWhere();
42 $set = $ilDB->query($sql);
43 if ($ilDB->numRows($set)) {
44 $row = $ilDB->fetchAssoc($set);
45 $this->properties->readRecord($row);
46 return true;
47 }
48 return false;
49 }
50
54 public function create()
55 {
56 global $ilDB;
57
58 $fields = $this->properties->getPrimary();
59 $this->properties->prepareInsert($fields);
60
61 $ilDB->insert($this->properties->getTable(), $fields);
62
63 // enables subtables
64 $this->properties->afterInsert();
65 }
66
70 public function update()
71 {
72 global $ilDB;
73
74 $fields = array();
75 $this->properties->prepareUpdate($fields);
76
77 // does return affected rows, but will also return 0 for unchanged records
78 $ilDB->update($this->properties->getTable(), $fields, $this->properties->getPrimary());
79
80 // enables subtables
81 $this->properties->afterUpdate();
82 }
83
87 public function delete()
88 {
89 global $ilDB;
90
91 $ilDB->manipulate("DELETE FROM " . $this->properties->getTable() .
92 " WHERE " . $this->properties->buildPrimaryWhere());
93
94 // enables subtables
95 $this->properties->afterDelete();
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
ADT Active Record helper class.
__construct(ilADTGroupDBBridge $a_properties)
Constructor.
create()
Create/insert record.
global $ilDB