ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
45 $row = $ilDB->fetchAssoc($set);
46 $this->properties->readRecord($row);
47 return true;
48 }
49 return false;
50 }
51
55 public function create()
56 {
57 global $ilDB;
58
59 $fields = $this->properties->getPrimary();
60 $this->properties->prepareInsert($fields);
61
62 $ilDB->insert($this->properties->getTable(), $fields);
63
64 // enables subtables
65 $this->properties->afterInsert();
66 }
67
71 public function update()
72 {
73 global $ilDB;
74
75 $fields = array();
76 $this->properties->prepareUpdate($fields);
77
78 // does return affected rows, but will also return 0 for unchanged records
79 $ilDB->update($this->properties->getTable(), $fields, $this->properties->getPrimary());
80
81 // enables subtables
82 $this->properties->afterUpdate();
83 }
84
88 public function delete()
89 {
90 global $ilDB;
91
92 $ilDB->manipulate("DELETE FROM ".$this->properties->getTable().
93 " WHERE ".$this->properties->buildPrimaryWhere());
94
95 // enables subtables
96 $this->properties->afterDelete();
97 }
98}
99
100?>
ADT Active Record helper class.
__construct(ilADTGroupDBBridge $a_properties)
Constructor.
create()
Create/insert record.
global $ilDB