/** * @return bool|void */ public function beforeExecuteRoute() { $this->registerOptions(); if (!parent::beforeExecuteRoute()) { return false; } $this->_currentVersion = join('.', sscanf(\Phalcon\Version::get(), '%d.%d.%d')); if (!$this->dispatcher->getParam('overwrite') && $this->db->tableExists((new Models\Versions())->getSource())) { $hasRecords = (bool) Models\Versions::count(['conditions' => 'version = ?0', 'bind' => [$this->_currentVersion]]); if ($hasRecords && !$this->confirm('Docs are already presents in the database. Do you want to overwrite it?')) { return false; } } }
protected function _hasVersion($version = null) { $version = $version ?: $this->dispatcher->getParam('version'); return (bool) Models\Versions::count(array('conditions' => 'version = ?0', 'bind' => array($version))); }