Added functionality to create joins using OOD
This commit is contained in:
parent
d93a02e779
commit
4fa01d4cc0
62
src/admin/common/abstract/model/join.php
Normal file
62
src/admin/common/abstract/model/join.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
abstract class AbstractCommonClubsModelJoin
|
||||
{
|
||||
|
||||
protected $tablename;
|
||||
protected $alias;
|
||||
protected $condition;
|
||||
/**
|
||||
* @var AbstractCommonClubsModelColumn[]
|
||||
*/
|
||||
protected $columns;
|
||||
|
||||
public function getAlias()
|
||||
{
|
||||
return $this->alias;
|
||||
}
|
||||
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->tablename;
|
||||
}
|
||||
|
||||
public function getOnCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param JDatabaseQuery $q
|
||||
*/
|
||||
public function join($q)
|
||||
{
|
||||
$str = "{$this->tablename} AS {$this->alias}";
|
||||
if(isset($this->condition))
|
||||
$str .= " ON {$this->condition}";
|
||||
$this->addJoin($q, $str);
|
||||
|
||||
foreach($this->columns as $c)
|
||||
{
|
||||
$qc = $q->q("{$this->alias}." . $c->getColumn(), $c->getAlias());
|
||||
$q->select($qc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param JDatabaseQuery $q
|
||||
* @param String $str
|
||||
*/
|
||||
protected abstract function addJoin($q, $str);
|
||||
|
||||
}
|
12
src/admin/common/models/join/innner.php
Normal file
12
src/admin/common/models/join/innner.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsModelJoinInner extends AbstractCommonClubsModelJoin
|
||||
{
|
||||
protected function addJoin($q, $str)
|
||||
{
|
||||
$q->innerJoin($str);
|
||||
}
|
||||
}
|
12
src/admin/common/models/join/left.php
Normal file
12
src/admin/common/models/join/left.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsModelJoinLeft extends AbstractCommonClubsModelJoin
|
||||
{
|
||||
protected function addJoin($q, $str)
|
||||
{
|
||||
$q->leftJoin($str);
|
||||
}
|
||||
}
|
12
src/admin/common/models/join/outer.php
Normal file
12
src/admin/common/models/join/outer.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsModelJoinOuter extends AbstractCommonClubsModelJoin
|
||||
{
|
||||
protected function addJoin($q, $str)
|
||||
{
|
||||
$q->outerJoin($str);
|
||||
}
|
||||
}
|
12
src/admin/common/models/join/right.php
Normal file
12
src/admin/common/models/join/right.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsModelJoinRight extends AbstractCommonClubsModelJoin
|
||||
{
|
||||
protected function addJoin($q, $str)
|
||||
{
|
||||
$q->rightJoin($str);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user