Created models for all database objects
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user