Removed minor bug and implemented stub of first class

This commit is contained in:
2019-05-22 14:22:45 +02:00
parent cb6068bfd6
commit b3e28d7884
6 changed files with 65 additions and 5 deletions

View File

@@ -94,7 +94,8 @@ abstract class AbstractCommonClubsModel
foreach($attribs as $k => $v)
{
$q->select($q->qn($v['col'], $k));
$rawColName = isset($v['col']) ? $v['col'] : $k;
$q->select($q->qn($rawColName, $k));
}
$q->from($factory->getTableName());
$q->where("id = {$this->id}");
@@ -253,7 +254,11 @@ abstract class AbstractCommonClubsModel
{
$q->insert($factory->getTableName());
$dbcols = array_map(function ($v){return $v['col'];}, $attribs);
$dbcols = array();
foreach($attribs as $k => $v)
{
$dbcols[] = isset($v['col']) ? $v['col'] : $k;
}
$q->columns($q->qn($dbcols));
@@ -282,7 +287,9 @@ abstract class AbstractCommonClubsModel
{
$q->update($factory->getTableName());
$dbcols = array_map(function ($v){return $v['col'];}, $attribs);
$dbcols = array();
foreach($attribs as $k => $v)
$dbcols[] = isset($v['col']) ? $v['col'] : $k;
$quotedData = $this->getQuotedData($attribs, $q);

View File

@@ -22,7 +22,7 @@ abstract class AbstractCommonClubsModelFactory
* )
*
* The inner arrays contain the following entries:
* - col: The name of the column in the database. Mandatory.
* - col: The name of the column in the database. Defaults to the key name
* - type: The type of the column. If nothing is specified, string is assumed.
* - string
* - int

View File

@@ -0,0 +1,14 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelClub extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryClub();
}
}

View File

@@ -0,0 +1,34 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryClub extends AbstractCommonClubsModelFactory
{
public function getAttributes()
{
return array(
'name'=>array(),
'address'=>array(),
'city'=>array(),
'homepage'=>array(),
'mail'=>array(),
'iban'=>array(),
'bic'=>array(),
'charitable'=>array('type'=>'int'),
'president'=>array('type'=>'int', 'ref'=>'CommonClubsModelUser')
);
}
public function getTableName()
{
return '#__club_clubs';
}
public function getClassName()
{
return 'CommonClubsModelClub';
}
}