Example #1
0
 public function sphinxTest($keyword, $cateid)
 {
     $keyword = $this->getSplitWd($keyword);
     $sphinxConfig = array("host" => "172.17.17.105", "port" => 9093);
     $conn = new \Foolz\SphinxQL\Connection();
     $conn->setParams(array('host' => $sphinxConfig["host"], 'port' => $sphinxConfig["port"]));
     $query = \Foolz\SphinxQL\SphinxQL::create($conn);
     $query->select(array("id", "cate3"))->from("product_distri_29");
     $query->where("cate3", "=", intval($cateid));
     $query->limit(0, 1000);
     $query->option("max_matches", 4000);
     try {
         $facet = Facet::create($conn)->facet('cate3')->limit(10)->orderby("count(*)", "desc");
         $query->facet($facet);
         echo $query->compileSelect()->getCompiled(), "\n";
         $sphinxRs = $query->executeBatch();
         var_dump($sphinxRs[1]);
         echo "\n";
         $sphinxql = new SphinxQL($conn);
         $total = $sphinxql->query('show meta');
         $total = $this->formatSphQLArray($total->execute());
         var_dump($total);
         exit;
     } catch (Exception $e) {
         return array();
     }
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['sphinxql'] = $this->app->share(function ($app) {
         $host = \Config::get('sphinxql::host');
         $port = \Config::get('sphinxql::port');
         $connection = new \Foolz\SphinxQL\Connection();
         $connection->setConnectionParams($host, $port);
         return new Sphinxql(new \Foolz\SphinxQL\SphinxQL($connection));
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../../config/config.php', 'shpinxql');
     $this->app->singleton('sphinxql', function ($app) {
         $host = $app['config']->get('sphinxql')['host'];
         $port = $app['config']->get('sphinxql')['port'];
         $connection = new \Foolz\SphinxQL\Connection();
         $connection->setConnectionParams($host, $port);
         return new Sphinxql(new \Foolz\SphinxQL\SphinxQL($connection));
     });
 }
Example #4
0
function testAction($cateid)
{
    $sphinxConfig = array("host" => "172.17.17.105", "port" => 9020);
    $conn = new \Foolz\SphinxQL\Connection();
    $conn->setParams(array('host' => $sphinxConfig["host"], 'port' => $sphinxConfig["port"]));
    $query = \Foolz\SphinxQL\SphinxQL::create($conn);
    $query->select(array("id", "cate3"))->from("product_distri_29");
    $query->where("cate3", "=", intval($cateid));
    $query->limit(0, 1000);
    $query->option("max_matches", 4000);
    try {
        echo $query->compileSelect()->getCompiled();
        echo "\n";
        exit;
        $sphinxRs = $query->execute();
        var_dump($sphinxRs);
        exit;
    } catch (Exception $e) {
        return array();
    }
}
Example #5
0
});
$di->setShared('annotations', function () {
    return new \Phalcon\Annotations\Adapter\Memory();
});
$di->setShared('response', function () {
    $response = new \Phalcon\Http\Response();
    return $response;
});
//注入DB服务
$di->setShared('gcoperator', function () use($di) {
    $dbclass = '\\Phalcon\\Db\\Adapter\\Pdo\\' . $di['config']->v3opDB->driver;
    return new $dbclass(array('host' => $di['config']->v3opDB->host, 'username' => $di['config']->v3opDB->username, 'password' => $di['config']->v3opDB->password, 'dbname' => $di['config']->v3opDB->database, 'charset' => $di['config']->v3opDB->charset));
});
//注入sphinx 服务
$di->setShared('sphinxCon', function () use($di) {
    $conn = new \Foolz\SphinxQL\Connection();
    $conn->setParams(array('host' => $di['config']->sphinx->host, 'port' => intval($di['config']->sphinx->port)));
    return $conn;
});
$di->setShared('filter', function () {
    $filter = new \Phalcon\Filter();
    $filter->add('price', function ($value) {
        return round(abs($value), 2);
    });
    return $filter;
});
$di->set('memObj', function () use($di) {
    $mcObj = new \Xz\Lib\Memcached($di['config']->memcommon);
    return $mcObj;
});
$di->set('request', function () {