addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'admin'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = 'import'; $this->name = 'avgPracovnici'; $this->briefDescription = ''; $this->detailedDescription = 'Jednorázový import pracovníku pro Avg'; } 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(); $filename = $this->configuration->getRootDir().DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'import'.DIRECTORY_SEPARATOR.'AVG_pracovnici.csv'; if (($handle = fopen($filename, "r")) !== false) { $filesize = filesize($filename); while (($row = fgetcsv($handle, $filesize, ";")) !== false) { $pracovnik = new Pracovnik(); $pracovnik->setZakaznikId(13); // AVG $pracovnik->setJmeno($row[0]); $pracovnik->setPrijmeni($row[1]); $pracovnik->setEmail($row[2]); $pracovnik->setPoznamka($row[3]); $pracovnik->save(); $this->logSection('pracovnik+', $pracovnik->getName()); } fclose($handle); } $this->log('Done'); } }