/** * Delete * * @param Where|\Closure|string|array $where * @return int */ public function delete($where) { if (!$this->isInitialized) { $this->initialize(); } $delete = $this->sql->delete(); if ($where instanceof \Closure) { $where($delete); } else { $delete->where($where); } return $this->executeDelete($delete); }
/** * Delete * * @return int */ public function delete() { $this->initialize(); if (!$this->rowExistsInDatabase()) { throw new Exception\RuntimeException('Cannot refresh the data not exists in database.'); } $where = $this->processPrimaryKeyWhere(); $statement = $this->sql->prepareStatement($this->sql->delete()->where($where)); $result = $statement->execute(); $rowsAffected = $result->getAffectedRows(); if ($rowsAffected == 1) { // detach from database $this->primaryKeyData = null; $this->data = array(); $this->cleanData = array(); } return $rowsAffected; }