Example #1
0
 /**
  *
  * @throws Exception
  * @return mixed
  */
 public function fetchOne()
 {
     if ($this->getKind() !== self::ROWS) {
         throw new Exception('Unexpected Response: ' . $this->getKind());
     }
     $this->offset = 4;
     $this->_metadata = $this->_metadata ? array_merge($this->_metadata, $this->_readMetadata()) : $this->_readMetadata();
     if (!isset($this->_metadata['columns'])) {
         throw new Exception('Missing Result Metadata');
     }
     $rowCount = parent::readInt();
     if ($rowCount === 0) {
         return null;
     }
     foreach ($this->_metadata['columns'] as $column) {
         return $this->readBytesAndConvertToType($column['type']);
     }
     return null;
 }