ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 26 of file class.ilADTActiveRecord.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTActiveRecord::__construct ( ilADTGroupDBBridge  $a_properties)

Constructor.

Parameters
ilADTGroupDBBridge$a_properties

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

37 {
38 global $DIC;
39
40 $this->db = $DIC->database();
41 $this->properties = $a_properties;
42 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ create()

ilADTActiveRecord::create ( )

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

64 : void
65 {
66 $fields = $this->properties->getPrimary();
67 $this->properties->prepareInsert($fields);
68 $this->db->insert($this->properties->getTable(), $fields);
69 $this->properties->afterInsert();
70 }

◆ delete()

ilADTActiveRecord::delete ( )

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

80 : void
81 {
82 $this->db->manipulate("DELETE FROM " . $this->properties->getTable() .
83 " WHERE " . $this->properties->buildPrimaryWhere());
84 $this->properties->afterDelete();
85 }

◆ read()

ilADTActiveRecord::read ( )

Read record.

Returns
bool

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

48 : bool
49 {
50 // reset all group elements
51 $this->properties->getADT()->reset();
52
53 $sql = "SELECT * FROM " . $this->properties->getTable() .
54 " WHERE " . $this->properties->buildPrimaryWhere();
55 $set = $this->db->query($sql);
56 if ($this->db->numRows($set)) {
57 $row = $this->db->fetchAssoc($set);
58 $this->properties->readRecord($row);
59 return true;
60 }
61 return false;
62 }

◆ update()

ilADTActiveRecord::update ( )

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

72 : void
73 {
74 $fields = array();
75 $this->properties->prepareUpdate($fields);
76 $this->db->update($this->properties->getTable(), $fields, $this->properties->getPrimary());
77 $this->properties->afterUpdate();
78 }

Field Documentation

◆ $db

ilDBInterface ilADTActiveRecord::$db
protected

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

◆ $properties

ilADTGroupDBBridge ilADTActiveRecord::$properties
protected

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


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