addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'zakaznik'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = ''; $this->name = 'spojitUcastniky'; $this->briefDescription = ''; $this->detailedDescription = ''; } protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $uchazeci = Doctrine::getTable('Uchazec')->createQuery() ->addWhere('pracovnik_id IS NULL') ->execute(); foreach($uchazeci as $uchazec) { if(is_null($uchazec->getZakaznikId())) { $zakaznik_id = $uchazec->getVlna()->getZakaznikId(); } else { $zakaznik_id = $uchazec->getZakaznikId(); } if(!is_null($zakaznik_id)) { $pracovnik = Doctrine::getTable('Pracovnik')->createQuery() ->addWhere('zakaznik_id = ?', $zakaznik_id) ->addWhere('email = ?', $uchazec->getEmail()) ->fetchOne(); if($pracovnik) { $uchazec->setPracovnikId($pracovnik->getId()); $uchazec->save(); $this->logSection('Uchazec', $uchazec->getJmeno()); } } } } }