コード例 #1
0
function _run_query($query)
{
    for ($i = 0; $i < vBSphinxSearch_Core::RECONNECT_LIMIT; $i++) {
        $con = vBSphinxSearch_Core::get_sphinxql_conection();
        if (false != $con) {
            $result_res = mysql_query($query, $con);
            if ($result_res) {
                $table_str = '<table id="results" name="results" border="1">';
                while ($docinfo = mysql_fetch_assoc($result_res)) {
                    // не эстетично, но быстро
                    $link = '';
                    if (isset($docinfo['primaryid'])) {
                        $thread['threadid'] = $docinfo['groupid'];
                        $thread['postidid'] = $docinfo['primaryid'];
                        $link = '<a href="' . fetch_seo_url('thread', $thread) . '#post' . $thread['postidid'] . '">' . $thread['postidid'] . '<a>';
                        $docinfo = array_merge(array('link' => $link), $docinfo);
                    }
                    $head = '<tr><td>' . implode('</td><td>', array_keys($docinfo)) . '</td></tr>';
                    $entry .= '<tr><td>' . implode('</td><td>', $docinfo) . '</td></tr>';
                }
                $table_str .= $head . $entry . '</table>';
                echo $table_str;
                return true;
            }
            echo 'Нет результатов<br />';
        }
    }
    echo 'Ошибка: <br />' . mysql_error() . '<br />';
    return false;
}
コード例 #2
0
 public function delete_group($group_id)
 {
     global $vbulletin;
     $indexer = vBSphinxSearch_Core::get_instance()->get_core_indexer();
     $sql = "SELECT\n                    " . $this->get_contenttypeid() . " AS contenttypeid,\n                    blog_text.blogtextid AS primaryid\n                FROM\n                    " . TABLE_PREFIX . "blog_text AS blog_text\n                LEFT JOIN\n                    " . TABLE_PREFIX . "blog AS blog ON blog.firstblogtextid = blog_text.blogtextid\n            \tWHERE\n                    blog_text.blogid = " . intval($group_id) . "\n                    AND blog.blogid IS NULL";
     $res = $vbulletin->db->query_read_slave($sql);
     while ($row = $vbulletin->db->fetch_array($res)) {
         $indexer->delete($row['contenttypeid'], $row['primaryid']);
     }
     return true;
 }
コード例 #3
0
ファイル: post.php プロジェクト: rcdesign/vb-sphinx_search
 /**
  * Called on thread hard-delete. Remove all posts from index.
  *
  * @param int $id the thread id
  */
 public function delete_thread($id)
 {
     global $vbulletin;
     $indexer = vBSphinxSearch_Core::get_instance()->get_core_indexer();
     $sql = "SELECT\r\n                    " . $this->get_contenttypeid() . " AS contenttypeid,\r\n                    post.postid AS primaryid\r\n                FROM\r\n                    " . TABLE_PREFIX . "post as post\r\n            \tWHERE\r\n                    post.threadid = " . intval($id);
     $res = $vbulletin->db->query_read_slave($sql);
     while ($row = $vbulletin->db->fetch_array($res)) {
         $indexer->delete($row['contenttypeid'], $row['primaryid']);
     }
     return true;
 }
コード例 #4
0
ファイル: core.php プロジェクト: rcdesign/vb-sphinx_search
 public static function get_sphinxql_conection()
 {
     global $vbulletin;
     if (!self::$_sphinx_conection or !mysql_ping(self::$_sphinx_conection)) {
         $host = $vbulletin->config['sphinx']['sql_host'];
         if ($host[0] == '/') {
             $connection_string = 'localhost:' . $host;
         } else {
             $port = $vbulletin->config['sphinx']['sql_port'];
             $connection_string = "{$host}:{$port}";
         }
         self::$_sphinx_conection = @mysql_connect($connection_string);
     }
     return self::$_sphinx_conection;
 }
コード例 #5
0
ファイル: indexer.php プロジェクト: rcdesign/vb-sphinx_search
 /**
  * Fetch list of ids by group_id. (For example - all posts by thread id)
  * 
  * Attention(!) Selection by pure attributes is ineffective in sphinx.
  * There will be problems for mass threads rebuild.
  * 
  * This code is for compatibility reasons, if optimised version
  * not implementer in index controler
  */
 protected function _fetch_object_id_list($group_id, $only_first = false)
 {
     if (is_null($this->_content_type_id) or 0 == (int) $group_id) {
         return false;
     }
     $indexes = implode(",", vBSphinxSearch_Core::get_sphinx_index_map($this->_content_type_id));
     if (empty($indexes)) {
         return false;
     }
     $limit = vBSphinxSearch_Core::SPH_DEFAULT_RESULTS_LIMIT;
     $query = 'SELECT *
                 FROM 
                     ' . $indexes . '
                 WHERE
                     contenttypeid = ' . $this->_content_type_id . ' AND
                     groupid = ' . $group_id . ($only_first ? ' AND isfirst = 1' : '') . '
                 LIMIT ' . $limit . ' OPTION max_matches=' . $limit;
     $this->_id_list = array();
     for ($i = 0; $i < vBSphinxSearch_Core::SPH_RECONNECT_LIMIT; $i++) {
         $con = vBSphinxSearch_Core::get_sphinxql_conection();
         if (false != $con) {
             $result_res = mysql_query($query, $con);
             if ($result_res) {
                 while ($docinfo = mysql_fetch_assoc($result_res)) {
                     $this->_id_list[] = $docinfo['primaryid'];
                 }
                 return true;
             }
         }
     }
     $error = mysql_error();
     $message = "\n\nSphinx: Can't get primaryid list for groupid={$group_id}\nUsed indexes: {$indexes}\n Error:\n{$error}\n";
     vBSphinxSearch_Core::log_errors($message);
     return false;
 }
コード例 #6
0
 /**
  * Set result limit.
  * 
  * Note: Set max_mathes option because default value is 500 
  *
  */
 protected function _set_limit($limit = null)
 {
     if (is_null($limit)) {
         $limit = vBSphinxSearch_Core::get_results_limit();
     }
     $this->_limit = $limit;
     $this->_options[] = 'max_matches=' . $this->_limit;
 }