ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilADTActiveRecord Class Reference

ADT Active Record helper class. More...

+ Collaboration diagram for ilADTActiveRecord:

Public Member Functions

 __construct (ilADTGroupDBBridge $a_properties)
 Constructor. More...
 
 read ()
 Read record. More...
 
 create ()
 Create/insert record. More...
 
 update ()
 Update record. More...
 
 delete ()
 Delete record. More...
 

Protected Attributes

 $properties
 

Detailed Description

ADT Active Record helper class.

This class expects a valid primary for all actions!

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 13 of file class.ilADTActiveRecord.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTActiveRecord::__construct ( ilADTGroupDBBridge  $a_properties)

Constructor.

Parameters
ilADTGroupDBBridge$a_properties
Returns
self

Definition at line 23 of file class.ilADTActiveRecord.php.

References properties.

24  {
25  $this->properties = $a_properties;
26  }
Set document properties

Member Function Documentation

◆ create()

ilADTActiveRecord::create ( )

Create/insert record.

Definition at line 54 of file class.ilADTActiveRecord.php.

References $ilDB, and properties.

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  }
global $ilDB
Set document properties

◆ delete()

ilADTActiveRecord::delete ( )

Delete record.

Definition at line 87 of file class.ilADTActiveRecord.php.

References $ilDB, and properties.

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  }
global $ilDB
Set document properties

◆ read()

ilADTActiveRecord::read ( )

Read record.

Returns
boolean

Definition at line 33 of file class.ilADTActiveRecord.php.

References $ilDB, $row, and properties.

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  }
global $ilDB
Set document properties

◆ update()

ilADTActiveRecord::update ( )

Update record.

Definition at line 70 of file class.ilADTActiveRecord.php.

References $ilDB, array, and properties.

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  }
Create styles array
The data for the language used.
global $ilDB
Set document properties

Field Documentation

◆ $properties

ilADTActiveRecord::$properties
protected

Definition at line 15 of file class.ilADTActiveRecord.php.


The documentation for this class was generated from the following file: