Get Data From Model With No Relation

guys …

i have 2 model they are model A, and model B.

i want to get data B from model A.

how can i get it?


Hi. I’m quite curious when you said “with no relation”. Do you mean there is no relation defined in both model A and model B? e.g.: hasOne, hasMany, etc?

What is the relationship between the 2 tables?

The only feasible way I could think of is perhaps using Yii2’s DB component and execute your own SQL query string.

$connection = \Yii::$app->db;

$command = $connection->createCommand('SELECT * FROM tableA');

$results = $command->queryAll();