/**
  * Insert a new User instance into the database.
  *
  * @param User $user
  */
 public function insert(User $user)
 {
     $this->dispatcher->dispatch(UserEvents::BEFORE_INSERT, new UserEvent($user));
     $sql = 'INSERT INTO ' . $this->conn->quoteIdentifier($this->userTableName) . '
         (' . $this->getUserColumns('email') . ', ' . $this->getUserColumns('password') . ', ' . $this->getUserColumns('salt') . ', ' . $this->getUserColumns('name') . ', ' . $this->getUserColumns('roles') . ', ' . $this->getUserColumns('time_created') . ', ' . $this->getUserColumns('username') . ', ' . $this->getUserColumns('isEnabled') . ', ' . $this->getUserColumns('confirmationToken') . ', ' . $this->getUserColumns('timePasswordResetRequested') . ')
         VALUES (:email, :password, :salt, :name, :roles, :timeCreated, :username, :isEnabled, :confirmationToken, :timePasswordResetRequested) ';
     $params = array('email' => $user->getEmail(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'name' => $user->getName(), 'roles' => implode(',', $user->getRoles()), 'timeCreated' => $user->getTimeCreated(), 'username' => $user->getRealUsername(), 'isEnabled' => $user->isEnabled(), 'confirmationToken' => $user->getConfirmationToken(), 'timePasswordResetRequested' => $user->getTimePasswordResetRequested());
     $this->conn->executeUpdate($sql, $params);
     $user->setId($this->conn->lastInsertId());
     $this->saveUserCustomFields($user);
     $this->identityMap[$user->getId()] = $user;
     $this->dispatcher->dispatch(UserEvents::AFTER_INSERT, new UserEvent($user));
 }
 /**
  * Insert a new User instance into the database.
  *
  * @param User $user
  */
 public function insert(User $user)
 {
     $sql = 'INSERT INTO users (email, password, salt, name, roles, time_created) VALUES (:email, :password, :salt, :name, :roles, :timeCreated) ';
     $params = array('email' => $user->getEmail(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'name' => $user->getName(), 'roles' => implode(',', $user->getRoles()), 'timeCreated' => $user->getTimeCreated());
     $this->conn->executeUpdate($sql, $params);
     $user->setId($this->conn->lastInsertId());
     $this->identityMap[$user->getId()] = $user;
 }