protected function addForeign($key, $ref, $col, $delete = null, $update = null)
    {
        if (empty($key)) {
            return Yii::t('podium/flash', 'Installation aborted! Foreign key name missing.');
        }
        if (empty($ref)) {
            return Yii::t('podium/flash', 'Installation aborted! Foreign key reference missing.');
        }
        if (empty($col)) {
            return Yii::t('podium/flash', 'Installation aborted! Referenced columns missing.');
        }
        try {
            $this->db->createCommand()->addForeignKey(
                    $this->getForeignName($key), $this->table, $key,
                    $this->getTableName($ref), $col, $delete, $update
                )->execute();
            return $this->returnSuccess(Yii::t('podium/flash', 'Table foreign key {name} has been added', [
                'name' => $this->getForeignName($key)
            ]));
        } catch (Exception $e) {
            return $this->returnError($e->getMessage(), __METHOD__,
                Yii::t('podium/flash', 'Error during table foreign key {name} adding', [
                    'name' => $this->getForeignName($key)
                ])
            );
        }
    }
protected function addForeign($key, $ref, $col, $delete = null, $update = null)
    {
        if (empty($key)) {
            return Yii::t('podium/flash', 'Installation aborted! Foreign key name missing.');
        }
        if (empty($ref)) {
            return Yii::t('podium/flash', 'Installation aborted! Foreign key reference missing.');
        }
        if (empty($col)) {
            return Yii::t('podium/flash', 'Installation aborted! Referenced columns missing.');
        }
        try {
            $this->db->createCommand()->addForeignKey(
                    $this->getForeignName($key), $this->table, $key,
                    $this->getTableName($ref), $col, $delete, $update
                )->execute();
            return $this->returnSuccess(Yii::t('podium/flash', 'Table foreign key {name} has been added', [
                'name' => $this->getForeignName($key)
            ]));
        } catch (Exception $e) {
            return $this->returnError($e->getMessage(), __METHOD__,
                Yii::t('podium/flash', 'Error during table foreign key {name} adding', [
                    'name' => $this->getForeignName($key)
                ])
            );
        }
    }
protected function addForeign ( $ key , $ ref , $ col , $ delete = null , $ update = null ) { if ( empty ( $ key ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Foreign key name missing.' ) ; } if ( empty ( $ ref ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Foreign key reference missing.' ) ; } if ( empty ( $ col ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Referenced columns missing.' ) ; } try { $ this -> db -> createCommand ( ) -> addForeignKey ( $ this -> getForeignName ( $ key ) , $ this -> table , $ key , $ this -> getTableName ( $ ref ) , $ col , $ delete , $ update ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table foreign key {name} has been added' , [ 'name' => $ this -> getForeignName ( $ key ) ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table foreign key {name} adding' , [ 'name' => $ this -> getForeignName ( $ key ) ] ) ) ; } }
Creates database table foreign key.
@param string|array $key key columns
@param string $ref key reference table
@param string|array $col reference table columns
@param string $delete ON DELETE action
@param string $update ON UPDATE action
@return string result message
@since 0.2
Creates database table foreign key .