Answer the question
In order to leave comments, you need to log in
How to issue a query in mySQL in Activerecord?
Actually, there is such a request
SELECT id, name_film, created_at
FROM `fl_films`
UNION
SELECT id, name_serial, created_at
FROM `fl_serial`
ORDER BY created_at DESC
LIMIT 0 , 20
Answer the question
In order to leave comments, you need to log in
It is difficult to solve the problem, but so the model is solved
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "fl_actours".
*
* @property integer $id
* @property string $name
* @property string $biography
*/
class FilmsFordate extends \yii\db\ActiveRecord
{
public static function tableName()
{
return 'fl_filmsFordate';
}
}?>
Yii::$app->db->createCommand(" CREATE OR REPLACE VIEW fl_filmsFordate(id,name,created_at) AS SELECT id, name_film, created_at FROM `fl_films`
UNION SELECT id, name_serial, created_at FROM `fl_serial` ORDER BY created_at DESC LIMIT 0 , 20");
$last= FilmsFordate::find()->all();
use query builder https://github.com/yiisoft/yii2/blob/master/docs/g...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question