Example #1
0
 /**
  * Удаление данные
  *
  * @param array|Cond $cond
  *
  * @throws Exception\ErrorException
  * @throws \Model\Exception\ErrorException
  * @return Result
  */
 public function delete($cond = null)
 {
     if (!is_array($cond) && !$cond instanceof Cond && !is_null($cond)) {
         throw new Exception\ErrorException('Unknown Cond type');
     }
     if (is_array($cond)) {
         $cond = $this->getCond()->where($cond);
     }
     $result = new Result();
     try {
         $select = $this->prepareSelect($cond);
         $table = $cond->getCond('from', $this->getRawName());
         $stmt = $this->getDb()->delete($table, $select);
         $result->setResult($stmt->rowCount());
     } catch (\Exception $ex) {
         $result->addError($ex->getMessage(), $ex->getCode());
     }
     return $result;
 }