/**
  * Sends a request over a communicator.
  * 
  * The only difference with the non private equivalent is that this one does
  * not do locking.
  * 
  * @param Communicator $com The communicator to send the request over.
  * 
  * @return int The number of bytes sent.
  * @see Client::sendSync()
  * @see Client::sendAsync()
  */
 private function _send(Communicator $com)
 {
     if (!$com->getTransmitter()->isAcceptingData()) {
         throw new SocketException('Transmitter is invalid. Sending aborted.', SocketException::CODE_REQUEST_SEND_FAIL);
     }
     $bytes = 0;
     $bytes += $com->sendWord($this->getCommand());
     if (null !== ($tag = $this->getTag())) {
         $bytes += $com->sendWord('.tag=' . $tag);
     }
     foreach ($this->attributes as $name => $value) {
         $prefix = '=' . $name . '=';
         if (is_string($value)) {
             $bytes += $com->sendWord($prefix . $value);
         } else {
             $bytes += $com->sendWordFromStream($prefix, $value);
         }
     }
     $query = $this->getQuery();
     if ($query instanceof Query) {
         $bytes += $query->send($com);
     }
     $bytes += $com->sendWord('');
     return $bytes;
 }
Exemple #2
0
 /**
  * Sends the query over a communicator.
  * 
  * The only difference with the non private equivalent is that this one does
  * not do locking.
  * 
  * @param Communicator $com The communicator to send the query over.
  * 
  * @return int The number of bytes sent.
  */
 private function _send(Communicator $com)
 {
     if (!$com->getTransmitter()->isAcceptingData()) {
         throw new SocketException('Transmitter is invalid. Sending aborted.', SocketException::CODE_QUERY_SEND_FAIL);
     }
     $bytes = 0;
     foreach ($this->words as $queryWord) {
         list($predicate, $value) = $queryWord;
         $prefix = '?' . $predicate;
         if (null === $value) {
             $bytes += $com->sendWord($prefix);
         } else {
             $prefix .= '=';
             if (is_string($value)) {
                 $bytes += $com->sendWord($prefix . $value);
             } else {
                 $bytes += $com->sendWordFromStream($prefix, $value);
             }
         }
     }
     return $bytes;
 }