當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sphPackI64函數代碼示例

本文整理匯總了PHP中sphPackI64函數的典型用法代碼示例。如果您正苦於以下問題:PHP sphPackI64函數的具體用法?PHP sphPackI64怎麽用?PHP sphPackI64使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sphPackI64函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: AddQuery

 function AddQuery($query, $index = "*", $comment = "")
 {
     // mbstring workaround
     $this->_MBPush();
     // build request
     $req = pack("NNNN", $this->_offset, $this->_limit, $this->_mode, $this->_ranker);
     if ($this->_ranker == SPH_RANK_EXPR) {
         $req .= pack("N", strlen($this->_rankexpr)) . $this->_rankexpr;
     }
     $req .= pack("N", $this->_sort);
     // (deprecated) sort mode
     $req .= pack("N", strlen($this->_sortby)) . $this->_sortby;
     $req .= pack("N", strlen($query)) . $query;
     // query itself
     $req .= pack("N", count($this->_weights));
     // weights
     foreach ($this->_weights as $weight) {
         $req .= pack("N", (int) $weight);
     }
     $req .= pack("N", strlen($index)) . $index;
     // indexes
     $req .= pack("N", 1);
     // id64 range marker
     $req .= sphPackU64($this->_min_id) . sphPackU64($this->_max_id);
     // id64 range
     // filters
     $req .= pack("N", count($this->_filters));
     foreach ($this->_filters as $filter) {
         $req .= pack("N", strlen($filter["attr"])) . $filter["attr"];
         $req .= pack("N", $filter["type"]);
         switch ($filter["type"]) {
             case SPH_FILTER_VALUES:
                 $req .= pack("N", count($filter["values"]));
                 foreach ($filter["values"] as $value) {
                     $req .= sphPackI64($value);
                 }
                 break;
             case SPH_FILTER_RANGE:
                 $req .= sphPackI64($filter["min"]) . sphPackI64($filter["max"]);
                 break;
             case SPH_FILTER_FLOATRANGE:
                 $req .= $this->_PackFloat($filter["min"]) . $this->_PackFloat($filter["max"]);
                 break;
             default:
                 assert(0 && "internal error: unhandled filter type");
         }
         $req .= pack("N", $filter["exclude"]);
     }
     // group-by clause, max-matches count, group-sort clause, cutoff count
     $req .= pack("NN", $this->_groupfunc, strlen($this->_groupby)) . $this->_groupby;
     $req .= pack("N", $this->_maxmatches);
     $req .= pack("N", strlen($this->_groupsort)) . $this->_groupsort;
     $req .= pack("NNN", $this->_cutoff, $this->_retrycount, $this->_retrydelay);
     $req .= pack("N", strlen($this->_groupdistinct)) . $this->_groupdistinct;
     // anchor point
     if (empty($this->_anchor)) {
         $req .= pack("N", 0);
     } else {
         $a =& $this->_anchor;
         $req .= pack("N", 1);
         $req .= pack("N", strlen($a["attrlat"])) . $a["attrlat"];
         $req .= pack("N", strlen($a["attrlong"])) . $a["attrlong"];
         $req .= $this->_PackFloat($a["lat"]) . $this->_PackFloat($a["long"]);
     }
     // per-index weights
     $req .= pack("N", count($this->_indexweights));
     foreach ($this->_indexweights as $idx => $weight) {
         $req .= pack("N", strlen($idx)) . $idx . pack("N", $weight);
     }
     // max query time
     $req .= pack("N", $this->_maxquerytime);
     // per-field weights
     $req .= pack("N", count($this->_fieldweights));
     foreach ($this->_fieldweights as $field => $weight) {
         $req .= pack("N", strlen($field)) . $field . pack("N", $weight);
     }
     // comment
     $req .= pack("N", strlen($comment)) . $comment;
     // attribute overrides
     $req .= pack("N", count($this->_overrides));
     foreach ($this->_overrides as $key => $entry) {
         $req .= pack("N", strlen($entry["attr"])) . $entry["attr"];
         $req .= pack("NN", $entry["type"], count($entry["values"]));
         foreach ($entry["values"] as $id => $val) {
             assert(is_numeric($id));
             assert(is_numeric($val));
             $req .= sphPackU64($id);
             switch ($entry["type"]) {
                 case SPH_ATTR_FLOAT:
                     $req .= $this->_PackFloat($val);
                     break;
                 case SPH_ATTR_BIGINT:
                     $req .= sphPackI64($val);
                     break;
                 default:
                     $req .= pack("N", $val);
                     break;
             }
         }
     }
//.........這裏部分代碼省略.........
開發者ID:makefifo,項目名稱:SphinxClient,代碼行數:101,代碼來源:SphinxClient.php

示例2: FilterOutput

 function FilterOutput()
 {
     $req = "";
     foreach ($this->_filters as $filter) {
         $req .= pack("N", strlen($filter["attr"])) . $filter["attr"];
         $req .= pack("N", $filter["type"]);
         switch ($filter["type"]) {
             case SPH_FILTER_VALUES:
                 $req .= pack("N", count($filter["values"]));
                 foreach ($filter["values"] as $value) {
                     $req .= sphPackI64($value);
                 }
                 break;
             case SPH_FILTER_RANGE:
                 $req .= sphPackI64($filter["min"]) . sphPackI64($filter["max"]);
                 break;
             case SPH_FILTER_FLOATRANGE:
                 $req .= $this->_PackFloat($filter["min"]) . $this->_PackFloat($filter["max"]);
                 break;
             default:
                 assert(0 && "internal error: unhandled filter type");
         }
         $req .= pack("N", $filter["exclude"]);
     }
     return $req;
 }
開發者ID:sulashidayat,項目名稱:plumboard,代碼行數:26,代碼來源:sphinxapi.2.0.1.php


注:本文中的sphPackI64函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。