爲什麼我不能向yii2應用程序添加多個用戶?我正在使用微軟sql服務器,yii2應用程序的註冊碼尚未更改。當用戶表中沒有記錄時,我可以使用yii的註冊頁面添加用戶。 這是DB腳本插入到Microsoft SQL Server用戶數據庫失敗
USE [IBR]
GO
/****** Object: Table [dbo].[user] Script Date: 11/05/2016 16.51.02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[user](
[id] [int] IDENTITY(1,1) NOT NULL,
[username] [nvarchar](255) NOT NULL,
[auth_key] [nvarchar](32) NOT NULL,
[password_hash] [nvarchar](255) NOT NULL,
[password_reset_token] [nvarchar](255) NULL,
[email] [nvarchar](255) NOT NULL,
[status] [smallint] NOT NULL DEFAULT ((10)),
[created_at] [int] NOT NULL,
[updated_at] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[password_reset_token] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[email] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
這是截圖。 error while signup for 2nd times
你從錯誤中沒有理解什麼?錯誤本身告訴你,你正在使用一個唯一列的重複值 –
好像你的查詢違反了表的唯一約束。檢查表中是否已有用戶名「Tari」的條目 – bmsqldev
看起來您根本沒有將數據插入到主鍵中。檢查你的表格結構並找出PK的位置。你需要插入一個唯一的值,在你試圖插入一個NULL的時候,但是那裏已經有一個值了。 –