News::find()->where(['category_id' => $id])->with('comments')->with('photos')->asArray()->limit(10)->all()
$m = new Migration();
$start = "INSERT INTO `display` (`hash`, `date`,`sum`, `news_id`) ";
$insert_data = [];
// $news_id = [здесь ваши ид];
// $date = ""; здесь дата
foreach ($news_id as $id)
{
$time = strtotime($date);
$hash = md5($id . $time);
$insert_data[] = " ('$hash', $time, 1, $id)";
}
$m->execute("$start VALUES " . implode(", ",$insert_data) . " ON DUPLICATE KEY UPDATE `sum` = `sum` + 1;");
$array = Yii::$app->assetManager->bundles;
namespace app\assets;
use yii\web\AssetBundle;
class CommonAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $js = [
'js/common.js'
];
public $depends = [
'zgb7mtr\colorPicker\ColorPickerAsset'
];
}
$data = User::find()->select(['FROM_UNIXTIME(created_at, "%Y-%m-%d") as date', 'COUNT(id) as value'])->where(['FROM_UNIXTIME(created_at, "%m")' => $month])->groupBy(['FROM_UNIXTIME(created_at, "%d")'])->asArray()->all();