protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); $count = 0; if (($handle = fopen(DATADIR . "/people/people.txt", "r")) !== FALSE) { while (($data = fgetcsv($handle)) !== FALSE) { $type = substr($data[2], 5, 1); switch ($type) { case 0: case 1: // This is a player $player = new Player($data[2]); $player->setName($data[1], $data[0]); $em->persist($player); //$output->writeln($player); break; case 8: // Managers and coaches $coach = new Coach($data[2]); $coach->setName($data[1], $data[0]); $em->persist($coach); break; case 9: // Umpires $umpire = new Umpire($data[2]); $umpire->setName($data[1], $data[0]); $em->persist($umpire); break; default: throw new \Exception('Unknown type of person record'); } if ($count % 500 == 0) { $em->flush(); $em->clear(); $output->writeln("flusing {$count}"); } $count++; } } fclose($handle); $em->flush(); }
public function __toString() { $this->_load(); return parent::__toString(); }
public function setBatter(Player $batter) { $this->batter = $batter; $batter->addBattingMatchup($this); }