예제 #1
0
 /**
  * Performs a N1QL query.
  *
  * @param CouchbaseN1qlQuery $queryObj
  * @return mixed
  * @throws CouchbaseException
  *
  * @internal
  */
 public function _n1ql($queryObj, $json_asarray)
 {
     $data = $queryObj->options;
     $dataStr = json_encode($data, true);
     $dataOut = $this->me->n1ql_request($dataStr, $queryObj->adhoc);
     $meta = json_decode($dataOut['meta'], true);
     if (isset($meta['errors']) && count($meta['errors']) > 0) {
         $err = $meta['errors'][0];
         $ex = new CouchbaseException($err['msg']);
         $ex->qCode = $err['code'];
         throw $ex;
     }
     $rows = array();
     foreach ($dataOut['results'] as $row) {
         $rows[] = json_decode($row, $json_asarray);
     }
     $result = array('rows' => $rows, 'status' => $meta['status'], 'metrics' => $meta['metrics']);
     return (object) $result;
 }
예제 #2
0
 /**
  * Performs a N1QL query.
  *
  * @param $dmlstring
  * @return mixed
  * @throws CouchbaseException
  *
  * @internal
  */
 public function _n1ql($queryObj, $params, $json_asarray)
 {
     $data = $queryObj->options;
     if (is_array($params)) {
         foreach ($params as $key => $value) {
             $data['$' . $key] = $value;
         }
     }
     $dataStr = json_encode($data, true);
     $dataOut = $this->me->n1ql_request($dataStr, $queryObj->adhoc);
     $meta = json_decode($dataOut['meta'], true);
     if (isset($meta['errors']) && count($meta['errors']) > 0) {
         $err = $meta['errors'][0];
         $ex = new CouchbaseException($err['msg']);
         $ex->qCode = $err['code'];
         throw $ex;
     }
     $rows = array();
     foreach ($dataOut['results'] as $row) {
         $rows[] = json_decode($row, $json_asarray);
     }
     return $rows;
 }