public function distinct($p, $cb)
    {
        $this->_params($p);
        $e = explode('.', $p['col'], 2);

        $query = [
            'distinct' => $e[1],
            'key' => $p['key'],
        ];

        if (isset($p[$k = 'rp'])) {
            $v = $p[$k];
            if (is_string($v)) {
                $v = ['mode' => $v];
            }
            $query['$readPreference'] = $v;
        }

        if (isset($p['where'])) {
            $query['query'] = $p['where'];
        }
        $cb = CallbackWrapper::wrap($cb);
        $this->request(
            self::OP_QUERY,
            pack('V', $p['opts']) . $e[0] . '.$cmd' . "\x00"
            . pack('VV', $p['offset'], $p['limit']) . bson_encode($query)
            . (isset($p['fields']) ? bson_encode($p['fields']) : ''),
            true,
            null,
            function ($conn, $reqId = null) use ($p, $cb) {
                if (!$conn) {
                    !$cb || $cb(['$err' => 'Connection error.']);
                    return;
                }
                $conn->requests[$reqId] = [$p['col'], $cb, true];
            }
        );
    }
public function distinct($p, $cb)
    {
        $this->_params($p);
        $e = explode('.', $p['col'], 2);

        $query = [
            'distinct' => $e[1],
            'key' => $p['key'],
        ];

        if (isset($p[$k = 'rp'])) {
            $v = $p[$k];
            if (is_string($v)) {
                $v = ['mode' => $v];
            }
            $query['$readPreference'] = $v;
        }

        if (isset($p['where'])) {
            $query['query'] = $p['where'];
        }
        $cb = CallbackWrapper::wrap($cb);
        $this->request(
            self::OP_QUERY,
            pack('V', $p['opts']) . $e[0] . '.$cmd' . "\x00"
            . pack('VV', $p['offset'], $p['limit']) . bson_encode($query)
            . (isset($p['fields']) ? bson_encode($p['fields']) : ''),
            true,
            null,
            function ($conn, $reqId = null) use ($p, $cb) {
                if (!$conn) {
                    !$cb || $cb(['$err' => 'Connection error.']);
                    return;
                }
                $conn->requests[$reqId] = [$p['col'], $cb, true];
            }
        );
    }
public function distinct ( $ p , $ cb ) { $ this -> _params ( $ p ) ; $ e = explode ( '.' , $ p [ 'col' ] , 2 ) ; $ query = [ 'distinct' => $ e [ 1 ] , 'key' => $ p [ 'key' ] , ] ; if ( isset ( $ p [ $ k = 'rp' ] ) ) { $ v = $ p [ $ k ] ; if ( is_string ( $ v ) ) { $ v = [ 'mode' => $ v ] ; } $ query [ '$readPreference' ] = $ v ; } if ( isset ( $ p [ 'where' ] ) ) { $ query [ 'query' ] = $ p [ 'where' ] ; } $ cb = CallbackWrapper :: wrap ( $ cb ) ; $ this -> request ( self :: OP_QUERY , pack ( 'V' , $ p [ 'opts' ] ) . $ e [ 0 ] . '.$cmd' . "\x00" . pack ( 'VV' , $ p [ 'offset' ] , $ p [ 'limit' ] ) . bson_encode ( $ query ) . ( isset ( $ p [ 'fields' ] ) ? bson_encode ( $ p [ 'fields' ] ) : '' ) , true , null , function ( $ conn , $ reqId = null ) use ( $ p , $ cb ) { if ( ! $ conn ) { ! $ cb || $ cb ( [ '$err' => 'Connection error.' ] ) ; return ; } $ conn -> requests [ $ reqId ] = [ $ p [ 'col' ] , $ cb , true ] ; } ) ; }
Returns distinct values of the property
@param  array $p Hash of properties (offset, limit, opts, key, col, where)
@param  callable $cb Callback called when response received
@callback $cb ( )
@return void
Returns distinct values of the property