Exemple #1
0
 /**
  * Finds the MetaBase model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MetaBase the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Meta::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #2
0
 public function searchTitle($key)
 {
     $path = Yii::$app->request->getPathInfo();
     $path = explode("/", $path);
     $routes = [];
     for ($i = count($path) - 1; $i > 0; $i--) {
         unset($path[$i]);
         $routes[] = Yii::$app->request->getHostInfo() . "/" . implode("/", $path);
     }
     $key[] = "MAX(CHAR_LENGTH(route))";
     $data = Meta::find()->select($key)->where("route in ('" . implode("','", $routes) . "')")->asArray()->one();
     return $data;
 }