ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTActiveRecord Class Reference

ADT Active Record helper class This class expects a valid primary for all actions! More...

+ Collaboration diagram for ilADTActiveRecord:

Public Member Functions

 __construct (ilADTGroupDBBridge $a_properties)
 Constructor. More...
 
 read ()
 Read record. More...
 
 create ()
 
 update ()
 
 delete ()
 

Protected Attributes

ilADTGroupDBBridge $properties
 
ilDBInterface $db
 

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

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

Constructor & Destructor Documentation

◆ __construct()

ilADTActiveRecord::__construct ( ilADTGroupDBBridge  $a_properties)

Constructor.

Parameters
ilADTGroupDBBridge$a_properties

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

References $DIC.

23  {
24  global $DIC;
25 
26  $this->db = $DIC->database();
27  $this->properties = $a_properties;
28  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ create()

ilADTActiveRecord::create ( )

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

50  : void
51  {
52  $fields = $this->properties->getPrimary();
53  $this->properties->prepareInsert($fields);
54  $this->db->insert($this->properties->getTable(), $fields);
55  $this->properties->afterInsert();
56  }

◆ delete()

ilADTActiveRecord::delete ( )

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

66  : void
67  {
68  $this->db->manipulate("DELETE FROM " . $this->properties->getTable() .
69  " WHERE " . $this->properties->buildPrimaryWhere());
70  $this->properties->afterDelete();
71  }

◆ read()

ilADTActiveRecord::read ( )

Read record.

Returns
bool

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

34  : bool
35  {
36  // reset all group elements
37  $this->properties->getADT()->reset();
38 
39  $sql = "SELECT * FROM " . $this->properties->getTable() .
40  " WHERE " . $this->properties->buildPrimaryWhere();
41  $set = $this->db->query($sql);
42  if ($this->db->numRows($set)) {
43  $row = $this->db->fetchAssoc($set);
44  $this->properties->readRecord($row);
45  return true;
46  }
47  return false;
48  }

◆ update()

ilADTActiveRecord::update ( )

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

58  : void
59  {
60  $fields = array();
61  $this->properties->prepareUpdate($fields);
62  $this->db->update($this->properties->getTable(), $fields, $this->properties->getPrimary());
63  $this->properties->afterUpdate();
64  }

Field Documentation

◆ $db

ilDBInterface ilADTActiveRecord::$db
protected

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

◆ $properties

ilADTGroupDBBridge ilADTActiveRecord::$properties
protected

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


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