Exemplo n.º 1
0
 protected function setPositionalArg($pos, Query $arg)
 {
     if (!is_numeric($pos)) {
         throw new RqlDriverError("Internal driver error: Got a non-numeric position for a positional argument.");
     }
     if ($arg->hasUnwrappedImplicitVar()) {
         $this->unwrappedImplicitVar = true;
     }
     $this->positionalArgs[$pos] = $arg;
 }
Exemplo n.º 2
0
 public function run(Query $query, $options = array(), &$profile = '')
 {
     if (isset($options) && !is_array($options)) {
         throw new RqlDriverError("Options must be an array.");
     }
     if (!$this->isOpen()) {
         throw new RqlDriverError("Not connected.");
     }
     // Grab PHP-RQL specific options
     $toNativeOptions = array();
     foreach (array('binaryFormat', 'timeFormat') as $opt) {
         if (isset($options) && isset($options[$opt])) {
             $toNativeOptions[$opt] = $options[$opt];
             unset($options[$opt]);
         }
     }
     // Generate a token for the request
     $token = $this->generateToken();
     // Send the request
     $globalOptargs = $this->convertOptions($options);
     if (isset($this->defaultDb) && !isset($options['db'])) {
         $globalOptargs['db'] = $this->defaultDb->encodeServerRequest();
     }
     $jsonQuery = array(QueryQueryType::PB_START, $query->encodeServerRequest(), (object) $globalOptargs);
     $this->sendQuery($token, $jsonQuery);
     if (isset($options['noreply']) && $options['noreply'] === true) {
         return null;
     }
     // Await the response
     $response = $this->receiveResponse($token, $query);
     if ($response['t'] == ResponseResponseType::PB_SUCCESS_PARTIAL) {
         $this->activeTokens[$token] = true;
     }
     if (isset($response['p'])) {
         $profile = $this->decodedJSONToDatum($response['p'])->toNative($toNativeOptions);
     }
     if ($response['t'] == ResponseResponseType::PB_SUCCESS_ATOM) {
         return $this->createDatumFromResponse($response)->toNative($toNativeOptions);
     } else {
         return $this->createCursorFromResponse($response, $token, $response['n'], $toNativeOptions);
     }
 }
Exemplo n.º 3
0
 public function wrapImplicitVar(Query $q)
 {
     if ($q->hasUnwrappedImplicitVar()) {
         return new RFunction(array(new RVar('_')), $q);
     } else {
         return $q;
     }
 }