toResultArray() public static method

Converts an exception to
public static toResultArray ( MongoDB\Driver\Exception\Exception $e ) : array
$e MongoDB\Driver\Exception\Exception
return array
コード例 #1
0
ファイル: MongoDB.php プロジェクト: alcaeus/mongo-php-adapter
 /**
  * Execute a database command
  *
  * @link http://www.php.net/manual/en/mongodb.command.php
  * @param array $data The query to send.
  * @param array $options
  * @return array Returns database response.
  */
 public function command(array $data, $options = [], &$hash = null)
 {
     try {
         $cursor = new \MongoCommandCursor($this->connection, $this->name, $data);
         $cursor->setReadPreference($this->getReadPreference());
         return iterator_to_array($cursor)[0];
     } catch (\MongoDB\Driver\Exception\Exception $e) {
         return ExceptionConverter::toResultArray($e);
     }
 }
コード例 #2
0
 /**
  * Delete all indexes for this collection
  *
  * @link http://www.php.net/manual/en/mongocollection.deleteindexes.php
  * @return array Returns the database response.
  */
 public function deleteIndexes()
 {
     try {
         return TypeConverter::toLegacy($this->collection->dropIndexes());
     } catch (\MongoDB\Driver\Exception\Exception $e) {
         return ExceptionConverter::toResultArray($e);
     }
 }