Y
Y
Yan_Alex2016-09-13 16:46:10
Yii
Yan_Alex, 2016-09-13 16:46:10

YII2 link generation for MyIsam tables?

Does YII 2.* have support for generating models with relationships through the COMMENT field for MyIsam tables? I tried to write CONSTRAINT FOREIGN KEY (name_of_this_field) REFERENCES related_table_name (related_field_name) in the comment of the related field, but it didn’t work for me.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton, 2016-09-13
@Yan_Alex

MYISAM does not support FOREIGN KEY. Use InnoDB for this. As for the COMMENT field, there is no such support.

D
Dmitry, 2016-09-13
@slo_nik

Good evening.
MyISAM type tables show relatively good...
No support, use InnoDB.
And connections can be made in models.

public funciton getName()
{
    return $this->hasOne(Model::className(), [по каким полям связываете])
}

M
Maxim Fedorov, 2016-09-13
@qonand

for the implementation of links in Yii2, it does not matter which engine is installed MyISAM, InnoDB or something else. You need to understand that foreign keys (FOREIGN KEY) are a mechanism that primarily provides data integrity and retrieval speed at the database level, but does not affect the data retrieval itself. I strongly recommend reading the data links information in the official documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question