ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilADTActiveRecord Class Reference

ADT Active Record helper class. More...

+ Collaboration diagram for ilADTActiveRecord:

Public Member Functions

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

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

ilADTActiveRecord::__construct ( ilADTGroupDBBridge  $a_properties)

Constructor.

Parameters
ilADTGroupDBBridge$a_properties
Returns
self

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

{
$this->properties = $a_properties;
}

Member Function Documentation

ilADTActiveRecord::create ( )

Create/insert record.

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

References $ilDB.

{
global $ilDB;
$fields = $this->properties->getPrimary();
$this->properties->prepareInsert($fields);
$ilDB->insert($this->properties->getTable(), $fields);
// enables subtables
$this->properties->afterInsert();
}
ilADTActiveRecord::delete ( )

Delete record.

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

References $ilDB.

{
global $ilDB;
$ilDB->manipulate("DELETE FROM ".$this->properties->getTable().
" WHERE ".$this->properties->buildPrimaryWhere());
// enables subtables
$this->properties->afterDelete();
}
ilADTActiveRecord::read ( )

Read record.

Returns
boolean

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

References $ilDB, and $row.

{
global $ilDB;
// reset all group elements
$this->properties->getADT()->reset();
$sql = "SELECT * FROM ".$this->properties->getTable().
" WHERE ".$this->properties->buildPrimaryWhere();
$set = $ilDB->query($sql);
if($ilDB->numRows($set))
{
$row = $ilDB->fetchAssoc($set);
$this->properties->readRecord($row);
return true;
}
return false;
}
ilADTActiveRecord::update ( )

Update record.

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

References $ilDB.

{
global $ilDB;
$fields = array();
$this->properties->prepareUpdate($fields);
// does return affected rows, but will also return 0 for unchanged records
$ilDB->update($this->properties->getTable(), $fields, $this->properties->getPrimary());
// enables subtables
$this->properties->afterUpdate();
}

Field Documentation

ilADTActiveRecord::$properties
protected

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


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