Skip to content
This repository has been archived by the owner on Aug 21, 2021. It is now read-only.

Commit

Permalink
7.2 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rdex committed Sep 27, 2017
1 parent 7a316af commit 972c3b6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions framework/db/ar/CActiveFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ class CJoinElement
public $rawTableAlias;

private $_finder;
/**
* @var CDbCommandBuilder $_builder
*/
private $_builder;
private $_parent;
private $_pkAlias; // string or name=>alias
Expand Down Expand Up @@ -1170,25 +1173,21 @@ private function joinManyMany($joinTable,$fks,$parent)
}
}

if(!$fkDefined)
{
$parentCondition=array();
$childCondition=array();
foreach($fks as $i=>$fk)
{
if($i<count($parent->_table->primaryKey))
{
$pk=is_array($parent->_table->primaryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey;
$parentCondition[$pk]=$parent->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);
}
else
{
$j=$i-count($parent->_table->primaryKey);
$pk=is_array($this->_table->primaryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey;
$childCondition[$pk]=$this->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);
}
}
}
if (!$fkDefined) {
$parentCondition = array();
$childCondition = array();
$primaryKeyCount = is_array($parent->_table->primaryKey) ? count($parent->_table->primaryKey) : 1;
foreach ($fks as $i => $fk) {
if ($i < $primaryKeyCount) {
$pk = is_array($parent->_table->primaryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey;
$parentCondition[$pk] = $parent->getColumnPrefix() . $schema->quoteColumnName($pk) . '=' . $joinAlias . '.' . $schema->quoteColumnName($fk);
} else {
$j = $i - $primaryKeyCount;
$pk = is_array($this->_table->primaryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey;
$childCondition[$pk] = $this->getColumnPrefix() . $schema->quoteColumnName($pk) . '=' . $joinAlias . '.' . $schema->quoteColumnName($fk);
}
}
}

if($parentCondition!==array() && $childCondition!==array())
{
Expand Down

0 comments on commit 972c3b6

Please sign in to comment.