/** * @return bool */ public final function close() { if (!$this->isEmpty()) { return false; } $this->clear(); return Buffer::close(); }
/** * @iterations 500 */ public function updating10times() { $idx = rand(0, count($this->_ids) - 1); $_id = $this->_ids[$idx]; $model = TestSchema::findOne($_id); Buffer::open(); for ($i = 0; $i < 10; $i++) { $model->title = 'updating ' . $i; if (!$model->save()) { throw new Exception(__METHOD__); } } Buffer::flush(); Buffer::close(); }
/** * Remove record from this collection * @param array $options * @throws Exception * @return bool */ public function delete(array $options = []) { if ($this->getIsNew()) { return false; } if ($this->beforeDelete() === false) { return false; } $options['multiple'] = false; if (!Buffer::add(Adapter::DELETE, $this, $options)) { if (!$this->forceDelete($options)) { return false; } } static::getCollection()->removeFromIdentityMap($this); $this->_id = null; $this->setIsNew(true); $this->afterDelete(); return true; }