src/Database/QueryBuilder/Commands/Create.php
/**
	 * Compiles a foreign key (automatically included in the schema).
	 *
	 * @param array $key
	 * @return string
	 */
Compiles a foreign key (automatically included in the schema).
@param array $key
@return string
Compiles a foreign key ( automatically included in the schema ) . @param array $key @return string
protected function compileForeignKey(array $key) {
		$compiled = array('FOREIGN KEY');
		$keyName = StringBuilder::formatColumnName('fk_' .
			$this->table .
			'_' . implode('_', $key['columns']) .
			'_' . $key['references']['table'] .
			'_' . implode('_', $key['references']['columns']));
		$compiled[] = $keyName;
		$compiled[] = sprintf('(%s)', $this->compileColumnList($key['columns']));
		$compiled[] = 'REFERENCES';
		$compiled[] = StringBuilder::formatTableName($this->builder->getPrefix() . $key['references']['table']);
		$compiled[] = sprintf('(%s)', $this->compileColumnList($key['references']['columns']));
		if (isset($key['onDelete'])) $compiled[] = 'ON DELETE ' . strtoupper($key['onDelete']);
		if (isset($key['onUpdate'])) $compiled[] = 'ON UPDATE ' . strtoupper($key['onUpdate']);
		return Str::join($compiled);
	}
protected function compileForeignKey ( array $ key ) { $ compiled = array ( 'FOREIGN KEY' ) ; $ keyName = StringBuilder :: formatColumnName ( 'fk_' . $ this -> table . '_' . implode ( '_' , $ key [ 'columns' ] ) . '_' . $ key [ 'references' ] [ 'table' ] . '_' . implode ( '_' , $ key [ 'references' ] [ 'columns' ] ) ) ; $ compiled [ ] = $ keyName ; $ compiled [ ] = sprintf ( '(%s)' , $ this -> compileColumnList ( $ key [ 'columns' ] ) ) ; $ compiled [ ] = 'REFERENCES' ; $ compiled [ ] = StringBuilder :: formatTableName ( $ this -> builder -> getPrefix ( ) . $ key [ 'references' ] [ 'table' ] ) ; $ compiled [ ] = sprintf ( '(%s)' , $ this -> compileColumnList ( $ key [ 'references' ] [ 'columns' ] ) ) ; if ( isset ( $ key [ 'onDelete' ] ) ) $ compiled [ ] = 'ON DELETE ' . strtoupper ( $ key [ 'onDelete' ] ) ; if ( isset ( $ key [ 'onUpdate' ] ) ) $ compiled [ ] = 'ON UPDATE ' . strtoupper ( $ key [ 'onUpdate' ] ) ; return Str :: join ( $ compiled ) ; }
Compiles a foreign key (automatically included in the schema).
Compiles a foreign key ( automatically included in the schema ) .
// Generate the unique foreign key name // Add the local column list // Add the reference // Add actions