read() public method

Read from document
public read ( string $query, array $options = [] ) : object
$query string
$options array
return object
 /**
  * Hack for embedded data
  */
 public function read($query, array $options = array())
 {
     if (!empty($options['embeddedData'])) {
         $params = compact('query', 'options');
         return $this->_filter(__METHOD__, $params, function ($self, $params) {
             return $params['options']['embeddedData'];
         });
     }
     return parent::read($query, $options);
 }
 public function read($query, array $options = array())
 {
     if (!empty($options['data'])) {
         $params = compact('query', 'options');
         $_config = $this->_config;
         return $this->_filter(__METHOD__, $params, function ($self, $params) use($_config) {
             $query = $params['query'];
             $config = compact('query') + array('class' => 'set');
             return $self->item($params['query']->model(), $params['options']['data'], $config);
         });
     }
     return parent::read($query, $options);
 }
Esempio n. 3
0
 public function testReadNoConnectionException()
 {
     $db = new MongoDb(array('host' => '__invalid__', 'autoConnect' => false));
     $this->assertException('Could not connect to the database.', function () use($db) {
         $db->read(null);
     });
 }
 public function testReadNoConnectionException()
 {
     $db = new MongoDb(array('host' => '__invalid__', 'autoConnect' => false));
     $this->expectException('Could not connect to the database.');
     $result = $db->read(null);
 }