Created models for all database objects

This commit is contained in:
2019-05-31 14:18:34 +02:00
parent 4fa01d4cc0
commit 4ce8fd274d
14 changed files with 634 additions and 11 deletions

View File

@@ -107,6 +107,12 @@ abstract class AbstractCommonClubsModel
$q->from($factory->getTableName());
$q->where("id = {$this->id}");
$joins = $factory->getJoins();
foreach($joins as $j)
{
$j->join($q);
}
$db->setQuery($q);
$db->execute();
@@ -130,12 +136,20 @@ abstract class AbstractCommonClubsModel
private function unpackExternalReferencesFromKeys($vals)
{
foreach($this->getFactory()->getAttributes() as $a)
$factory = $this->getFactory();
foreach($factory->getAttributes() as $a)
{
$alias = $a->getAlias();
$vals[$alias] = $a->unpackValue($vals[$alias]);
}
$joins = $factory->getJoins();
foreach($joins as $join)
{
$join->unpackExternalReferencesFromKeys($vals);
}
return $vals;
}
@@ -243,6 +257,10 @@ abstract class AbstractCommonClubsModel
$q->where("id = {$this->id}");
}
/**
*
* @param JDatabaseDriver $db
*/
protected function prepareDelete($db)
{}
@@ -267,11 +285,28 @@ abstract class AbstractCommonClubsModel
*
* @param AbstractCommonClubsModelFactory $factory
* @param string $colName
* @param array $constraints
*/
protected function fetchAssociatedElements($factory, $colName)
protected function fetchAssociatedElements($factory, $colName, $constraints = null, $sorting = null)
{
$condition = "main.$colName = {$this->id}";
return $factory->loadElements($condition);
if(isset($constraints))
{
if(is_array($constraints))
$allConstraints = clone $constraints;
elseif(is_string($constraints))
$allConstraints = array($constraints);
else
throw new Exception('Unknown type of constraint');
// Add the manual condition to match the current object
$allConstraints[] = $condition;
return $factory->loadElements($allConstraints, $sorting);
}
else
$factory->loadElements($condition, $sorting);
}
protected function filterPackData($values)