Beispiel #1
0
 /**
  *
  * @param int $consistency
  * @param array $options
  * @return string
  */
 public static function queryParameters($consistency, array $options = [])
 {
     $flags = 0;
     $optional = '';
     if (isset($options['serial_consistency'])) {
         $flags |= Query::FLAG_WITH_SERIAL_CONSISTENCY;
         $optional .= pack('n', $options['serial_consistency']);
     }
     if (isset($options['default_timestamp'])) {
         $flags |= Query::FLAG_WITH_DEFAULT_TIMESTAMP;
         $optional .= Type\Bigint::binary($options['default_timestamp']);
     }
     if (!empty($options['names_for_values'])) {
         /**
          * @link https://github.com/duoshuo/php-cassandra/issues/40
          */
         throw new \Cassandra\Exception('NAMES_FOR_VALUES in batch request seems never work in Cassandra 2.1.x.  Keep NAMES_FOR_VALUES flag false to avoid this bug.');
         $flags |= Query::FLAG_WITH_NAMES_FOR_VALUES;
     }
     return pack('n', $consistency) . pack('C', $flags) . $optional;
 }
Beispiel #2
0
 /**
  * 
  * @param int $consistency
  * @param array $values
  * @param array $options
  * @return string
  */
 public static function queryParameters($consistency, array $values = [], array $options = [])
 {
     $flags = 0;
     $optional = '';
     if (!empty($values)) {
         $flags |= Query::FLAG_VALUES;
         $optional .= Request::valuesBinary($values, !empty($options['names_for_values']));
     }
     if (!empty($options['skip_metadata'])) {
         $flags |= Query::FLAG_SKIP_METADATA;
     }
     if (isset($options['page_size'])) {
         $flags |= Query::FLAG_PAGE_SIZE;
         $optional .= pack('N', $options['page_size']);
     }
     if (isset($options['paging_state'])) {
         $flags |= Query::FLAG_WITH_PAGING_STATE;
         $optional .= pack('N', strlen($options['paging_state'])) . $options['paging_state'];
     }
     if (isset($options['serial_consistency'])) {
         $flags |= Query::FLAG_WITH_SERIAL_CONSISTENCY;
         $optional .= pack('n', $options['serial_consistency']);
     }
     if (isset($options['default_timestamp'])) {
         $flags |= Query::FLAG_WITH_DEFAULT_TIMESTAMP;
         $bigint = new Type\Bigint($options['default_timestamp']);
         $optional .= $bigint->getBinary();
     }
     if (!empty($options['names_for_values'])) {
         $flags |= Query::FLAG_WITH_NAMES_FOR_VALUES;
     }
     return pack('n', $consistency) . pack('C', $flags) . $optional;
 }