yii\mongodb\Collection::remove PHP Method

remove() public method

Removes data from the collection.
public remove ( array $condition = [], array $options = [] ) : integer | boolean
$condition array description of records to remove.
$options array list of options in format: optionName => optionValue.
return integer | boolean number of updated documents or whether operation was successful.
    public function remove($condition = [], $options = [])
    {
        $options = array_merge(['limit' => 0], $options);
        $writeResult = $this->database->createCommand()->delete($this->name, $condition, $options);
        return $writeResult->getDeletedCount();
    }

Usage Example

コード例 #1
0
ファイル: Collection.php プロジェクト: sciurodont/yii2
 /**
  * Removes data from the collection.
  * @param array $condition description of records to remove.
  * @param array $options list of options in format: optionName => optionValue.
  * @return integer|boolean number of updated documents or whether operation was successful.
  * @throws Exception on failure.
  */
 public function remove($condition = [], $options = [])
 {
     $result = parent::remove($condition, $options);
     $this->tryLastError();
     // MongoGridFS::remove will return even if the remove failed
     return $result;
 }