Dropped database JOINs
Not being used and the logic is pretty damn hacky. I don't believe in JOINs so I'm unsure if this support will be re-added in the future or if there will simply be a backed in opinion that JOINs are the devil.
This commit is contained in:
parent
9cc466bcd3
commit
8655045097
2 changed files with 1 additions and 75 deletions
|
@ -122,16 +122,6 @@ class Model extends Object
|
||||||
*/
|
*/
|
||||||
protected $table = false;
|
protected $table = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Joins
|
|
||||||
*
|
|
||||||
* SQL: JOIN
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var mixed
|
|
||||||
*/
|
|
||||||
protected $joins = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conditions
|
* Conditions
|
||||||
*
|
*
|
||||||
|
@ -692,52 +682,6 @@ class Model extends Object
|
||||||
*/
|
*/
|
||||||
private function generateQuery()
|
private function generateQuery()
|
||||||
{
|
{
|
||||||
// Adds the JOIN syntax
|
|
||||||
// @todo Ton of issues with predefined columns
|
|
||||||
if ($this->joins != false)
|
|
||||||
{
|
|
||||||
if (is_array($this->joins))
|
|
||||||
{
|
|
||||||
foreach ($this->joins as $join => $tables)
|
|
||||||
{
|
|
||||||
$join_pieces = [(stripos('JOIN ', $join) === false ? 'JOIN' : strtoupper($join))];
|
|
||||||
|
|
||||||
if (is_array($tables))
|
|
||||||
{
|
|
||||||
foreach ($tables as $table => $conditions)
|
|
||||||
{
|
|
||||||
$join_pieces[] = $table;
|
|
||||||
|
|
||||||
if (is_array($conditions))
|
|
||||||
{
|
|
||||||
$type = strtoupper(key($conditions));
|
|
||||||
$conditions = current($conditions);
|
|
||||||
|
|
||||||
$join_pieces[] = $type;
|
|
||||||
$join_pieces[] = $this->generateConditions($conditions, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$join_pieces = $conditions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$join_pieces[] = $tables;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sql[] = implode(' ', $join_pieces);
|
|
||||||
|
|
||||||
unset($join_pieces);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->sql[] = (stripos('JOIN ', $this->joins) === false ? 'JOIN ' : '') . $this->joins;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the WHERE conditionals
|
// Adds the WHERE conditionals
|
||||||
if ($this->conditions != false)
|
if ($this->conditions != false)
|
||||||
{
|
{
|
||||||
|
@ -1621,7 +1565,7 @@ class Model extends Object
|
||||||
$key = trim(strtolower($key));
|
$key = trim(strtolower($key));
|
||||||
|
|
||||||
// Assigns valid keys to the appropriate class property
|
// Assigns valid keys to the appropriate class property
|
||||||
if (in_array($key, ['fields', 'table', 'joins', 'conditions', 'group', 'having', 'order', 'limit', 'offset']))
|
if (in_array($key, ['fields', 'table', 'conditions', 'group', 'having', 'order', 'limit', 'offset']))
|
||||||
{
|
{
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
$conditions = false;
|
$conditions = false;
|
||||||
|
|
|
@ -158,24 +158,6 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals([2 => 'one'], $model->records);
|
$this->assertEquals([2 => 'one'], $model->records);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testJoinsString()
|
|
||||||
{
|
|
||||||
$model = new MockModelWithoutColumns([
|
|
||||||
'conditions' => ['pickles.id' => 1],
|
|
||||||
'joins' => 'brines ON brines.pickle_id = pickles.id',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testJoinsArray()
|
|
||||||
{
|
|
||||||
$model = new MockModelWithoutColumns([
|
|
||||||
'conditions' => ['pickles.id' => 1],
|
|
||||||
'joins' => [
|
|
||||||
'INNER JOIN' => 'brines ON brines.pickle_id = pickles.id',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFieldValues()
|
public function testFieldValues()
|
||||||
{
|
{
|
||||||
$model = new MockModel('all');
|
$model = new MockModel('all');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue