"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/db/ar/CActiveFinder.php" between
yii-1.1.19.5790cb.tar.gz and yii-1.1.20.6ed384.tar.gz

About: Yii is a high-performance component-based PHP framework for developing large-scale Web applications. Hint: Yii 1.1 is now in maintenance mode.

CActiveFinder.php  (yii-1.1.19.5790cb):CActiveFinder.php  (yii-1.1.20.6ed384)
skipping to change at line 590 skipping to change at line 590
break; break;
} }
} }
if(!$fkDefined) if(!$fkDefined)
{ {
$parentCondition=array(); $parentCondition=array();
$childCondition=array(); $childCondition=array();
$count=0; $count=0;
$params=array(); $params=array();
$pkCount=is_array($parent->_table->primaryKey)?co unt($parent->_table->primaryKey):1;
foreach($fks as $i=>$fk) foreach($fks as $i=>$fk)
{ {
if($i<count($parent->_table->primaryKey)) if($i<$pkCount)
{ {
$pk=is_array($parent->_table->pri maryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey; $pk=is_array($parent->_table->pri maryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey;
$parentCondition[$pk]=$joinAlias. '.'.$schema->quoteColumnName($fk).'=:ypl'.$count; $parentCondition[$pk]=$joinAlias. '.'.$schema->quoteColumnName($fk).'=:ypl'.$count;
$params[':ypl'.$count]=$record->$ pk; $params[':ypl'.$count]=$record->$ pk;
$count++; $count++;
} }
else else
{ {
$j=$i-count($parent->_table->prim aryKey); $j=$i-$pkCount;
$pk=is_array($this->_table->prima ryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey; $pk=is_array($this->_table->prima ryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey;
$childCondition[$pk]=$this->getCo lumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColu mnName($fk); $childCondition[$pk]=$this->getCo lumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColu mnName($fk);
} }
} }
} }
if($parentCondition!==array() && $childCondition!==array( )) if($parentCondition!==array() && $childCondition!==array( ))
{ {
$join='INNER JOIN '.$joinTable->rawName.' '.$join Alias.' ON '; $join='INNER JOIN '.$joinTable->rawName.' '.$join Alias.' ON ';
$join.='('.implode(') AND (',$parentCondition).') AND ('.implode(') AND (',$childCondition).')'; $join.='('.implode(') AND (',$parentCondition).') AND ('.implode(') AND (',$childCondition).')';
skipping to change at line 1175 skipping to change at line 1176
{ {
$fkDefined=false; $fkDefined=false;
break; break;
} }
} }
if(!$fkDefined) if(!$fkDefined)
{ {
$parentCondition=array(); $parentCondition=array();
$childCondition=array(); $childCondition=array();
$pkCount=is_array($parent->_table->primaryKey)?count($par ent->_table->primaryKey):1;
foreach($fks as $i=>$fk) foreach($fks as $i=>$fk)
{ {
if($i<count($parent->_table->primaryKey)) if($i<$pkCount)
{ {
$pk=is_array($parent->_table->primaryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey; $pk=is_array($parent->_table->primaryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey;
$parentCondition[$pk]=$parent->getColumnP refix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnNam e($fk); $parentCondition[$pk]=$parent->getColumnP refix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnNam e($fk);
} }
else else
{ {
$j=$i-count($parent->_table->primaryKey); $j=$i-$pkCount;
$pk=is_array($this->_table->primaryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey; $pk=is_array($this->_table->primaryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey;
$childCondition[$pk]=$this->getColumnPref ix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($ fk); $childCondition[$pk]=$this->getColumnPref ix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($ fk);
} }
} }
} }
if($parentCondition!==array() && $childCondition!==array()) if($parentCondition!==array() && $childCondition!==array())
{ {
$join=$this->relation->joinType.' '.$joinTable->rawName.' '.$joinAlias; $join=$this->relation->joinType.' '.$joinTable->rawName.' '.$joinAlias;
skipping to change at line 1426 skipping to change at line 1428
private function queryOneMany() private function queryOneMany()
{ {
$relation=$this->relation; $relation=$this->relation;
$model=$this->_finder->getModel($relation->className); $model=$this->_finder->getModel($relation->className);
$builder=$model->getCommandBuilder(); $builder=$model->getCommandBuilder();
$schema=$builder->getSchema(); $schema=$builder->getSchema();
$table=$model->getTableSchema(); $table=$model->getTableSchema();
$parent=$this->_parent; $parent=$this->_parent;
$pkTable=$parent->model->getTableSchema(); $pkTable=$parent->model->getTableSchema();
$pkCount=is_array($pkTable->primaryKey)?count($pkTable->primaryKe y):1;
$fks=preg_split('/\s*,\s*/',$relation->foreignKey,-1,PREG_SPLIT_N O_EMPTY); $fks=preg_split('/\s*,\s*/',$relation->foreignKey,-1,PREG_SPLIT_N O_EMPTY);
if(count($fks)!==count($pkTable->primaryKey)) if(count($fks)!==$pkCount)
throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is specified with an invalid foreign key. The columns in the key must match the primary keys of the table "{table}".', throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is specified with an invalid foreign key. The columns in the key must match the primary keys of the table "{table}".',
array('{class}'=>get_class($paren t->model), '{relation}'=>$relation->name, '{table}'=>$pkTable->name))); array('{class}'=>get_class($paren t->model), '{relation}'=>$relation->name, '{table}'=>$pkTable->name)));
// set up mapping between fk and pk columns // set up mapping between fk and pk columns
$map=array(); // pk=>fk $map=array(); // pk=>fk
foreach($fks as $i=>$fk) foreach($fks as $i=>$fk)
{ {
if(!isset($table->columns[$fk])) if(!isset($table->columns[$fk]))
throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with an invalid fore ign key "{key}". There is no such column in the table "{table}".', throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with an invalid fore ign key "{key}". There is no such column in the table "{table}".',
array('{class}'=>get_class($parent->model ), '{relation}'=>$relation->name, '{key}'=>$fk, '{table}'=>$table->name))); array('{class}'=>get_class($parent->model ), '{relation}'=>$relation->name, '{key}'=>$fk, '{table}'=>$table->name)));
skipping to change at line 1534 skipping to change at line 1537
/** /**
* @param string $joinTableName jointablename * @param string $joinTableName jointablename
* @param string $keys keys * @param string $keys keys
* @throws CDbException * @throws CDbException
*/ */
private function queryManyMany($joinTableName,$keys) private function queryManyMany($joinTableName,$keys)
{ {
$relation=$this->relation; $relation=$this->relation;
$model=$this->_finder->getModel($relation->className); $model=$this->_finder->getModel($relation->className);
$table=$model->getTableSchema(); $table=$model->getTableSchema();
$pkCount=is_array($table->primaryKey)?count($table->primaryKey):1 ;
$builder=$model->getCommandBuilder(); $builder=$model->getCommandBuilder();
$schema=$builder->getSchema(); $schema=$builder->getSchema();
$pkTable=$this->_parent->model->getTableSchema(); $pkTable=$this->_parent->model->getTableSchema();
$pkCountPk=is_array($pkTable->primaryKey)?count($pkTable->primary Key):1;
$tableAlias=$model->getTableAlias(true); $tableAlias=$model->getTableAlias(true);
if(($joinTable=$builder->getSchema()->getTable($joinTableName))== =null) if(($joinTable=$builder->getSchema()->getTable($joinTableName))== =null)
throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is not specified correctly: the join tabl e "{joinTable}" given in the foreign key cannot be found in the database.', throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is not specified correctly: the join tabl e "{joinTable}" given in the foreign key cannot be found in the database.',
array('{class}'=>get_class($this->_parent->model) , '{relation}'=>$relation->name, '{joinTable}'=>$joinTableName))); array('{class}'=>get_class($this->_parent->model) , '{relation}'=>$relation->name, '{joinTable}'=>$joinTableName)));
$fks=preg_split('/\s*,\s*/',$keys,-1,PREG_SPLIT_NO_EMPTY); $fks=preg_split('/\s*,\s*/',$keys,-1,PREG_SPLIT_NO_EMPTY);
if(count($fks)!==count($table->primaryKey)+count($pkTable->primar yKey)) if(count($fks)!==$pkCount+$pkCountPk)
throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is specified with an incomplete foreign k ey. The foreign key must consist of columns referencing both joining tables.', throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is specified with an incomplete foreign k ey. The foreign key must consist of columns referencing both joining tables.',
array('{class}'=>get_class($this->_parent->model) , '{relation}'=>$relation->name))); array('{class}'=>get_class($this->_parent->model) , '{relation}'=>$relation->name)));
$joinCondition=array(); $joinCondition=array();
$map=array(); $map=array();
$fkDefined=true; $fkDefined=true;
foreach($fks as $i=>$fk) foreach($fks as $i=>$fk)
{ {
if(!isset($joinTable->columns[$fk])) if(!isset($joinTable->columns[$fk]))
skipping to change at line 1585 skipping to change at line 1590
break; break;
} }
} }
if(!$fkDefined) if(!$fkDefined)
{ {
$joinCondition=array(); $joinCondition=array();
$map=array(); $map=array();
foreach($fks as $i=>$fk) foreach($fks as $i=>$fk)
{ {
if($i<count($pkTable->primaryKey)) if($i<$pkCountPk)
{ {
$pk=is_array($pkTable->primaryKey) ? $pkT able->primaryKey[$i] : $pkTable->primaryKey; $pk=is_array($pkTable->primaryKey) ? $pkT able->primaryKey[$i] : $pkTable->primaryKey;
$map[$pk]=$fk; $map[$pk]=$fk;
} }
else else
{ {
$j=$i-count($pkTable->primaryKey); $j=$i-$pkCountPk;
$pk=is_array($table->primaryKey) ? $table ->primaryKey[$j] : $table->primaryKey; $pk=is_array($table->primaryKey) ? $table ->primaryKey[$j] : $table->primaryKey;
$joinCondition[$pk]=$tableAlias.'.'.$sche ma->quoteColumnName($pk).'='.$joinTable->rawName.'.'.$schema->quoteColumnName($f k); $joinCondition[$pk]=$tableAlias.'.'.$sche ma->quoteColumnName($pk).'='.$joinTable->rawName.'.'.$schema->quoteColumnName($f k);
} }
} }
} }
if($joinCondition===array() || $map===array()) if($joinCondition===array() || $map===array())
throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is specified with an incomplete foreign k ey. The foreign key must consist of columns referencing both joining tables.', throw new CDbException(Yii::t('yii','The relation "{relat ion}" in active record class "{class}" is specified with an incomplete foreign k ey. The foreign key must consist of columns referencing both joining tables.',
array('{class}'=>get_class($this->_parent->model) , '{relation}'=>$relation->name))); array('{class}'=>get_class($this->_parent->model) , '{relation}'=>$relation->name)));
 End of changes. 13 change blocks. 
8 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)