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; }