framework/gii/generators/model/ModelCode.php
protected function isRelationTable($table)
	{
		$pk=$table->primaryKey;
        $count=is_array($pk) ? count($pk) : 1;
        return ($count === 2 // we want 2 columns
			&& isset($table->foreignKeys[$pk[0]]) // pk column 1 is also a foreign key
			&& isset($table->foreignKeys[$pk[1]]) // pk column 2 is also a foriegn key
			&& $table->foreignKeys[$pk[0]][0] !== $table->foreignKeys[$pk[1]][0]); // and the foreign keys point different tables
	}
protected function isRelationTable($table)
	{
		$pk=$table->primaryKey;
        $count=is_array($pk) ? count($pk) : 1;
        return ($count === 2 // we want 2 columns
			&& isset($table->foreignKeys[$pk[0]]) // pk column 1 is also a foreign key
			&& isset($table->foreignKeys[$pk[1]]) // pk column 2 is also a foriegn key
			&& $table->foreignKeys[$pk[0]][0] !== $table->foreignKeys[$pk[1]][0]); // and the foreign keys point different tables
	}
protected function isRelationTable ( $ table ) { $ pk = $ table -> primaryKey ; $ count = is_array ( $ pk ) ? count ( $ pk ) : 1 ; return ( $ count === 2 // we want 2 columns && isset ( $ table -> foreignKeys [ $ pk [ 0 ] ] ) // pk column 1 is also a foreign key && isset ( $ table -> foreignKeys [ $ pk [ 1 ] ] ) // pk column 2 is also a foriegn key && $ table -> foreignKeys [ $ pk [ 0 ] ] [ 0 ] !== $ table -> foreignKeys [ $ pk [ 1 ] ] [ 0 ] ) ; // and the foreign keys point different tables }
Checks if the given table is a "many to many" pivot table.
Their PK has 2 fields, and both of those fields are also FK to other separate tables.
@param CDbTableSchema table to inspect
@return boolean true if table matches description of helper table.
Checks if the given table is a many to many pivot table . Their PK has 2 fields and both of those fields are also FK to other separate tables .