PHP 连接 Druid.IO 驱动服务的扩展 PHP-Druid

码农软件 · 软件分类 · PHP开发工具 · 2019-11-09 17:26:53

软件介绍

这是一个为 PHP 连接查询 Druid.IO 提供的客户端驱动服务的 PHP 扩展。

安装

Make Install PHP-Druid

$ /path/to/phpize
$ ./configure --with-php-config=/path/to/php-config
$ make && make install

PECL Install PHP-Druid

$ pecl install Druid

配置

Druid.ini

extension=druid.so
druid.base_auth_passport = ""
druid.base_auth_user = ""
druid.debug = 1
druid.host = "http://10.0.3.46:9082/druid/v2/"
druid.tpl_path = "/data/php-druid/tpl"
druid.curl_dns_cache_timeout = 1
druid.curl_connect_timeout = 3
druid.curl_timeout = 5

Demo

<?php
    /**
     * @author neeke@php.net
     * Date: 16/12/21 下午8:38
     */

    try {

        $Druid_1 = Druid::getInstance();
        $Druid_1->debugWitch(TRUE);

        /**
         * you can also use default host with druid.host in php.ini/druid.ini
         */
        $aHosts = array("http://10.0.3.46:9082/druid/v2/", "http://10.0.3.46:9082/druid/v2/");
        $Druid_1->setDruidHosts($aHosts);

        /**
         * demo 1
         *
         * use tpl build request json
         */
        $Druid_1->setTplPath(__DIR__ . '/tpl');
        $result_1 = $Druid_1->getDataByTpl('request_tpl_demo.json', array('@startTimeToEndTime@' => '["2016-12-10T14:06:00.000Z/2016-12-27T14:36:00.000Z"]'));


        $Druid_2 = Druid::getInstance('druid_2_instance');
        /**
         * demo 2
         *
         * use full request json
         */
        $result_2 = $Druid_2->getData(file_get_contents(__DIR__ . '/tpl/request_full_demo.json'));

        var_dump($result_1, $result_2);
        var_dump($Druid_1,$Druid_2);
    } catch (Exception $e) {
        var_dump($e->getCode(), $e->getMessage(), $Druid_1->getDebugInfo(), $Druid_2->getDebugInfo());
    }

本文地址:https://www.codercto.com/soft/d/18626.html

Beginning XML with DOM and Ajax

Beginning XML with DOM and Ajax

Sas Jacobs / Apress / 2006-06-05 / USD 39.99

Don't waste time on 1,000-page tomes full of syntax; this book is all you need to get ahead in XML development. Renowned web developer Sas Jacobs presents an essential guide to XML. Beginning XML with......一起来看看 《Beginning XML with DOM and Ajax》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具