validate() public method

Validates this collection
public validate ( boolean $scan_data = FALSE ) : array
$scan_data boolean Only validate indices, not the base collection.
return array Returns the database's evaluation of this object.
    public function testValidate() {
      $v = $this->object->validate();
      $this->assertEquals((bool)$v['ok'], false);
      $this->assertEquals($v['errmsg'], 'ns not found');

      $this->object->insert(array('a' => 'foo'));
      $v = $this->object->validate();
      $this->assertEquals((bool)$v['ok'], true);
      $this->assertEquals($v['ns'], 'phpunit.c');
    }
 public function testValidate()
 {
     $v = $this->object->validate();
     $this->assertEquals($v['ok'], 0);
     $this->assertEquals($v['errmsg'], 'ns not found');
     $this->object->insert(array('a' => 'foo'));
     $v = $this->object->validate();
     $this->assertEquals($v['ok'], 1);
     $this->assertEquals($v['ns'], 'phpunit.c');
     $this->assertNotNull($v['result']);
 }
示例#3
0
 /**
  * Validates a collection. The method scans a collection’s data structures
  * for correctness and returns a single document that describes the
  * relationship between the logical collection and the physical
  * representation of the data.
  *
  * @link http://docs.mongodb.org/manual/reference/method/db.collection.validate/
  * @param bool $full Specify true to enable a full validation and to return
  *      full statistics. MongoDB disables full validation by default because it
  *      is a potentially resource-intensive operation.
  * @return array
  * @throws Exception
  */
 public function validate($full = false)
 {
     $response = $this->_mongoCollection->validate($full);
     if (!$response || $response['ok'] != 1) {
         throw new Exception($response['errmsg']);
     }
     return $response;
 }
示例#4
0
 /**
  * Wrapper method for MongoCollection::validate().
  *
  * @see http://php.net/manual/en/mongocollection.validate.php
  * @param string $scanData
  * @return array
  */
 public function validate($scanData = false)
 {
     return $this->mongoCollection->validate($scanData);
 }
示例#5
0
 /**
  * validate.
  */
 public function validate($scanData = false)
 {
     $this->time->start();
     $return = parent::validate($scanData);
     $time = $this->time->stop();
     $this->log(array('type' => 'validate', 'scanData' => $scanData, 'time' => $time));
     return $return;
 }