ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

Member Function Documentation

◆ create()

ilADTActiveRecord::create ( )

Create/insert record.

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

References $DIC, and $ilDB.

57  {
58  global $DIC;
59 
60  $ilDB = $DIC['ilDB'];
61 
62  $fields = $this->properties->getPrimary();
63  $this->properties->prepareInsert($fields);
64 
65  $ilDB->insert($this->properties->getTable(), $fields);
66 
67  // enables subtables
68  $this->properties->afterInsert();
69  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ delete()

ilADTActiveRecord::delete ( )

Delete record.

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

References $DIC, and $ilDB.

94  {
95  global $DIC;
96 
97  $ilDB = $DIC['ilDB'];
98 
99  $ilDB->manipulate("DELETE FROM " . $this->properties->getTable() .
100  " WHERE " . $this->properties->buildPrimaryWhere());
101 
102  // enables subtables
103  $this->properties->afterDelete();
104  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ read()

ilADTActiveRecord::read ( )

Read record.

Returns
boolean

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

References $DIC, $ilDB, and $row.

34  {
35  global $DIC;
36 
37  $ilDB = $DIC['ilDB'];
38 
39  // reset all group elements
40  $this->properties->getADT()->reset();
41 
42  $sql = "SELECT * FROM " . $this->properties->getTable() .
43  " WHERE " . $this->properties->buildPrimaryWhere();
44  $set = $ilDB->query($sql);
45  if ($ilDB->numRows($set)) {
46  $row = $ilDB->fetchAssoc($set);
47  $this->properties->readRecord($row);
48  return true;
49  }
50  return false;
51  }
global $DIC
Definition: saml.php:7
$row
global $ilDB

◆ update()

ilADTActiveRecord::update ( )

Update record.

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

References $DIC, and $ilDB.

75  {
76  global $DIC;
77 
78  $ilDB = $DIC['ilDB'];
79 
80  $fields = array();
81  $this->properties->prepareUpdate($fields);
82 
83  // does return affected rows, but will also return 0 for unchanged records
84  $ilDB->update($this->properties->getTable(), $fields, $this->properties->getPrimary());
85 
86  // enables subtables
87  $this->properties->afterUpdate();
88  }
global $DIC
Definition: saml.php:7
global $ilDB

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: