ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionFieldProp.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
17 protected $id; // [int]
18 protected $datatype_property_id; //[int]
19 protected $value; //[string]
20 protected $field_id; // [int]
21
22
29 public function __construct($a_id = 0)
30 {
31 if ($a_id != 0)
32 {
33 $this->id = $a_id;
34 $this->doRead();
35 }
36 }
37
43 public function setId($a_id)
44 {
45 $this->id = $a_id;
46 }
47
53 public function getId()
54 {
55 return $this->id;
56 }
57
63 public function setDatatypePropertyId($a_id)
64 {
65 $this->datatype_property_id = $a_id;
66 }
67
73 public function getDatatypePropertyId()
74 {
76 }
77
83 public function setValue($a_value)
84 {
85 $this->value = $a_value;
86 }
87
93 public function getValue()
94 {
95 return $this->value;
96 }
97
103 public function setFieldId($a_id)
104 {
105 $this->field_id = $a_id;
106 }
107
113 public function getFieldId()
114 {
115 return $this->field_id;
116 }
117
118
122 public function doRead()
123 {
124 global $ilDB;
125
126 $query = "SELECT * FROM il_dcl_field_prop WHERE id = ".$ilDB->quote($this->getId(),"integer");
127 $set = $ilDB->query($query);
128 $rec = $ilDB->fetchAssoc($set);
129
130 $this->setDatatypePropertyId($rec["datatype_prop_id"]);
131 $this->setValue($rec["value"]);
132 $this->setFieldId($rec["field_id"]);
133
134 }
135
136
140 public function doCreate()
141 {
142 global $ilDB;
143
144 $id = $ilDB->nextId("il_dcl_field_prop");
145 $this->setId($id);
146 $query = "INSERT INTO il_dcl_field_prop (".
147 "id".
148 ", datatype_prop_id".
149 ", field_id".
150 ", value".
151 " ) VALUES (".
152 $ilDB->quote($this->getId(), "integer")
153 .",".$ilDB->quote($this->getDatatypePropertyId(), "integer")
154 .",".$ilDB->quote($this->getFieldId(), "integer")
155 .",".$ilDB->quote($this->getValue(), "text")
156 .")";
157 $ilDB->manipulate($query);
158 }
159
160
164 public function doUpdate()
165 {
166 global $ilDB;
169 $sql = "SELECT * FROM il_dcl_field_prop WHERE datatype_prop_id = " . $ilDB->quote($this->getDatatypePropertyId(), 'integer') .
170 " AND field_id = " . $ilDB->quote($this->getFieldId(), 'integer');
171 $set = $ilDB->query($sql);
172 if (!$ilDB->numRows($set)) {
173 $this->doCreate();
174 return;
175 }
176
177 $ilDB->update("il_dcl_field_prop", array(
178 "datatype_prop_id" => array("integer", $this->getDatatypePropertyId()),
179 "field_id" => array("integer", $this->getFieldId()),
180 "value" => array("text", $this->getValue())
181 ), array(
182 "datatype_prop_id" => array("integer", $this->getDatatypePropertyId()),
183 "field_id" => array("integer", $this->getFieldId())
184 ));
185 }
186}
187
188
189?>
Class ilDataCollectionFieldProp.
global $ilDB