Ejemplo n.º 1
0
 /**
  * @param ObjectManager $manager
  * @throws \Doctrine\DBAL\DBALException
  */
 protected function loadClients(ObjectManager $manager)
 {
     echo "\nClients ... ";
     $stmt = $this->connection->executeQuery('SELECT * FROM client');
     foreach ($stmt->fetchAll() as $i => $record) {
         $client = new Client();
         $client->setFirstname($record['firstname']);
         $client->setLastname($record['lastname']);
         $client->setOrigin($record['origin']);
         $client->setPhone($record['phone']);
         $client->setEmailAddress($record['email_address']);
         $client->setIsEmailConfirmed($record['email_confirmed']);
         $client->setCreated(\DateTime::createFromFormat('Y-m-d H:i:s', preg_replace('/\\.[0-9]+$/', '', $record['created_at'])));
         $client->setUpdated(\DateTime::createFromFormat('Y-m-d H:i:s', preg_replace('/\\.[0-9]+$/', '', $record['updated_at'])));
         $manager->persist($client);
         $i += 1;
         $this->addReference("client-" . $record['id'], $client);
     }
 }