ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 55 of file class.ilADTActiveRecord.php.

References $ilDB, and properties.

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

◆ delete()

ilADTActiveRecord::delete ( )

Delete record.

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

References $ilDB, and properties.

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  }
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  {
45  $row = $ilDB->fetchAssoc($set);
46  $this->properties->readRecord($row);
47  return true;
48  }
49  return false;
50  }
global $ilDB
Set document properties

◆ update()

ilADTActiveRecord::update ( )

Update record.

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

References $ilDB, array, and properties.

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  }
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: