/** * Saves the supplied user to the database * * @param UserVO $userVO * @throws \Exception */ public function save(UserVO $userVO) { $params = ['email' => $userVO->getEmail(), 'user_name' => $userVO->getUserName(), 'user_password' => $userVO->getUserPassword()]; $request = $this->queryBuilder->insert(self::TABLE)->values($params); if (!$request->execute($params)) { throw new \Exception('User cannot be saved'); } }
public function install() { try { $this->queryBuilder->createDatabase(Config::getDatabaseName())->useDatabase(Config::getDatabaseName())->createTable('users', ['user_id' => 'smallint(6) NOT NULL PRIMARY KEY AUTO_INCREMENT', 'user_name' => 'varchar(30) NOT NULL', 'email' => 'varchar(30) NOT NULL', 'user_password' => 'char(60) NOT NULL'], ['ENGINE=InnoDB', 'DEFAULT CHARSET=utf8']); } catch (\Exception $e) { echo $e->getMessage(); } }