コード例 #1
0
 /**
  * Generate settings for comments caching
  *
  * @param string $model comment's model name
  * @param int $model_id comment's model id
  * @param int $duration
  * @return array
  */
 public static function getCacheProperties($model, $model_id = '', $duration = 3600)
 {
     $tableName = Comment::tableName();
     return ['duration' => $duration, 'dependency' => ['class' => 'yii\\caching\\DbDependency', 'sql' => "SELECT COUNT(*) FROM {$tableName} " . "WHERE `model` = '{$model}' AND `model_id` = '{$model_id}'"]];
 }