Ejemplo n.º 1
0
 /**
  * Deletes documents with the specified primary keys.
  * See {@link find()} for detailed explanation about $condition and $params.
  * @param mixed[] $pkValues Primary keys array
  * @param array|CriteriaInterface $criteria query criteria.
  * @since v1.0
  */
 public function deleteAllByPk($pkValues, $criteria = null)
 {
     if ($this->_beforeDelete()) {
         $criteria = $this->sm->apply($criteria);
         $criteria->mergeWith(PkManager::prepareAll($this->model, $pkValues, $criteria));
         $result = $this->getCollection()->remove($criteria->getConditions(), $this->options->getSaveOptions(['justOne' => false]));
         return $this->_result($result);
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Finds all documents with the specified primary keys.
  * In MongoDB world every document has '_id' unique field, so with this method that
  * field is in use as PK by default.
  * See {@link find()} for detailed explanation about $condition.
  *
  * @param mixed $pkValues primary key value(s). Use array for multiple primary keys. For composite key, each key value must be an array (column name=>column value).
  * @param array|CriteriaInterface $criteria query criteria.
  * @return AnnotatedInterface[]|Cursor - Array or cursor of Documents
  * @since v1.0
  */
 public function findAllByPk($pkValues, $criteria = null)
 {
     $pkCriteria = new Criteria($criteria);
     $pkCriteria->decorateWith($this->model);
     PkManager::prepareAll($this->model, $pkValues, $pkCriteria);
     return $this->findAll($pkCriteria);
 }