src/Builder/AssociationsBuilder.php
public function prepareHasAndBelongsToManyConstraintStatement($type_name, $connection_table, $constraint_name, $field_name)
    {
        $result = [];

        $result[] = 'ALTER TABLE ' . $this->getConnection()->escapeTableName($connection_table);
        $result[] = '    ADD CONSTRAINT ' . $this->getConnection()->escapeFieldName($constraint_name);
        $result[] = '    FOREIGN KEY (' . $field_name . ') REFERENCES ' . $this->getConnection()->escapeTableName($type_name) . '(`id`)';
        $result[] = '    ON UPDATE CASCADE ON DELETE CASCADE;';

        return implode("\n", $result);
    }
public function prepareHasAndBelongsToManyConstraintStatement($type_name, $connection_table, $constraint_name, $field_name)
    {
        $result = [];

        $result[] = 'ALTER TABLE ' . $this->getConnection()->escapeTableName($connection_table);
        $result[] = '    ADD CONSTRAINT ' . $this->getConnection()->escapeFieldName($constraint_name);
        $result[] = '    FOREIGN KEY (' . $field_name . ') REFERENCES ' . $this->getConnection()->escapeTableName($type_name) . '(`id`)';
        $result[] = '    ON UPDATE CASCADE ON DELETE CASCADE;';

        return implode("\n", $result);
    }
public function prepareHasAndBelongsToManyConstraintStatement ( $ type_name , $ connection_table , $ constraint_name , $ field_name ) { $ result = [ ] ; $ result [ ] = 'ALTER TABLE ' . $ this -> getConnection ( ) -> escapeTableName ( $ connection_table ) ; $ result [ ] = '    ADD CONSTRAINT ' . $ this -> getConnection ( ) -> escapeFieldName ( $ constraint_name ) ; $ result [ ] = '    FOREIGN KEY (' . $ field_name . ') REFERENCES ' . $ this -> getConnection ( ) -> escapeTableName ( $ type_name ) . '(`id`)' ; $ result [ ] = '    ON UPDATE CASCADE ON DELETE CASCADE;' ; return implode ( "\n" , $ result ) ; }
Prepare has and belongs to many constraint statement.

@param  string $type_name
@param  string $connection_table
@param  string $constraint_name
@param  string $field_name
@return string
Prepare has and belongs to many constraint statement .