Return dependencies form entities to other entities (in our case these are all the DB relations)
{
if (!$a_rec && !$a_ids) {
return false;
}
switch ($a_entity) {
case 'dcl':
$set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
return array(
'il_dcl_table' => array( 'ids' => $ids ),
);
break;
case 'il_dcl_table':
$set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids_records = $this->
buildCache(
'il_dcl_record', $set);
$set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids_fields = $this->
buildCache(
'il_dcl_field', $set);
$set = $this->db->query('SELECT * FROM il_dcl_view WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids_views = $this->
buildCache(
'il_dcl_view', $set);
return array(
'il_dcl_field' => array( 'ids' => $ids_fields ),
'il_dcl_record' => array( 'ids' => $ids_records ),
'il_dcl_view' => array( 'ids' => $ids_views ),
);
case 'il_dcl_field':
$set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids = $this->
buildCache(
'il_dcl_field_prop', $set);
return array(
'il_dcl_field_prop' => array( 'ids' => $ids ),
);
case 'il_dcl_record':
$sql = 'SELECT rf.*, d.storage_location FROM il_dcl_record_field AS rf' . ' INNER JOIN il_dcl_field AS f ON (f.id = rf.field_id)'
. ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
. $this->db->quote($a_rec['id'], 'integer');
$set = $this->db->query($sql);
$ids = $this->
buildCache(
'il_dcl_record_field', $set);
$set = $this->db->query($sql);
while ($rec = $this->db->fetchObject($set)) {
$this->record_field_ids_2_storage[$rec->id] = $rec->storage_location;
}
$sql =
'SELECT rf.id AS record_field_id, st1.value AS value1, st2.value AS value2, st3.value AS value3 FROM il_dcl_record_field AS rf '
. 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
. 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
. 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
. $this->db->quote($a_rec['id'], 'integer');
$set = $this->db->query($sql);
while ($rec = $this->db->fetchObject($set)) {
$stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
$value = "value{$stloc}";
$this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
'record_field_id' => $rec->record_field_id,
'value' => $rec->{$value}
);
}
return array(
'il_dcl_record_field' => array( 'ids' => $ids )
);
case 'il_dcl_view':
$set = $this->db->query('SELECT * FROM il_dcl_viewdefinition WHERE view_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids = $this->
buildCache(
'il_dcl_viewdefinition', $set);
return array(
'il_dcl_viewdefinition' => array( 'ids' => $ids )
);
case 'il_dcl_record_field':
$record_field_id = $a_rec['id'];
$storage_loc = $this->record_field_ids_2_storage[$record_field_id];
return array(
"il_dcl_stloc{$storage_loc}_value" => array( 'ids' => array( $record_field_id ) )
);
}
return false;
}