第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

求幫助老師

Caught exception: 注冊(cè)失敗 Array ( [userId] => 0 [username] => admin1 [createAt] => 1502333216 ),老師我這個(gè)問(wèn)題什么情況,我的userId設(shè)置的是自增的

我的代碼

user.php

public function register($username,$password)
? ?{
? ? ? ?if (empty($username)) {
? ? ? ? ? ?throw new Exception('用戶名不能為空', ErrorCode::USERNAME_CANNOT_EMPTY);
? ? ? ?}
? ? ? ?if (empty($password)) {
? ? ? ? ? ?throw new Exception('密碼不能為空', ErrorCode::PASSWORD_CANNOT_EMPTY);
? ? ? ?}
? ? ? ?if ($this->_isUsernameExists($username)) {
? ? ? ? ? ?throw new Exception('用戶名已存在', ErrorCode::USERNAME_EXISTS);
? ? ? ?}
? ? ? ?//寫入數(shù)據(jù)庫(kù)
? ? ? ?$sql = "INSERT INTO 'user'('username','password','createdAt') VALUES (:username,:password,:createdAt)";
? ? ? ?$createdAt = time();
? ? ? ?$password = $this->_md5($password);
? ? ? ?$stmt = $this->_db->prepare($sql);
? ? ? ?$stmt->bindParam(':username', $username);
? ? ? ?$stmt->bindParam(':password', $password);
? ? ? ?$stmt->bindParam(':createdAt', $createdAt);
// ? ? ? ?print_r($stmt);exit();

? ? ? ?if (!$stmt->execute()) {
? ? ? ? ? ?try{
? ? ? ? ? ?throw new Exception('注冊(cè)失敗', ErrorCode::REGISTER_FAIL);
? ? ? ? ? ?}catch (Exception $e) {
? ? ? ? ? ? ? ?echo 'Caught exception: ', ?$e->getMessage(),'<br>';
? ? ? ? ? ?}
? ? ? ?}

? ? ? ?return[
? ? ? ?'userId' => $this->_db->lastInsertId(),
? ? ? ?'username' => $username,
? ? ? ?'createAt' => $createdAt
? ? ? ?];
? ?}

index.php

require_once __DIR__.'/lib/User.php';
$pdo = require __DIR__.'/lib/db.php';
$user=new User($pdo);
//print_r( $pdo -> errorInfo(), true);
print_r($user->register('admin1','admin1s'));

正在回答

1 回答

...

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)