addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = 'tmp'; $this->name = 'script'; $this->briefDescription = ''; $this->detailedDescription = ''; } /** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); sfContext::createInstance($this->configuration); $this->fixActualPrice(); } public function fixActualPrice() { $items = Doctrine::getTable('Item')->createQuery('i') ->leftJoin('i.Bids as b') ->addWhere('b.id IS NULL') // ->offset($options['offset']) // ->limit($options['limit']) ->execute(); foreach ($items as $item) { if(!$item->hasBids()) { $item->setPriceActual(0); $item->save(); $this->logSection('Item', 'done: ' . $item->getId()); } } $this->logSection('Items', 'finish'); } public function genereteNicknames() { $users = Doctrine::getTable('User')->createQuery() // ->offset($options['offset']) // ->limit($options['limit']) ->execute(); foreach ($users as $user) { $user->generateNickname(); $user->save(); $this->logSection('User', 'done: ' . $user->getNickname()); } $this->logSection('Users', 'finish'); } }