예제 #1
0
 public function search($q)
 {
     $result = [];
     foreach ($this->indexs as $config) {
         /** @var \hightman\xunsearch\Database $db */
         $db = \Yii::createObject(["class" => Database::className(), "iniFile" => $config, "charset" => "utf-8"]);
         $result = array_merge($result, $db->getSearch()->search($q));
     }
     $models = [];
     /** @var \XSDocument $item */
     foreach ($result as $item) {
         $models[] = $item["entity"]::findOne($item["id"]);
     }
     return $models;
 }
예제 #2
0
 /**
  * Open database
  * @param string $name database name.
  * @return Database
  * @throws \XSException
  */
 protected function openDatabase($name)
 {
     $this->trigger(self::EVENT_BEFORE_OPEN);
     $iniFile = $this->iniDirectory . '/' . $name . '.ini';
     return Yii::createObject(['class' => Database::className(), 'charset' => $this->charset, 'iniFile' => $iniFile]);
 }
예제 #3
0
 public function afterUpdate()
 {
     $this->db->update(new \XSDocument($this->getColumns()));
 }