【发布时间】:2015-01-21 03:35:41
【问题描述】:
我想输入 customername、pan、mobile 列的组合必须唯一的行,所以我使用了
$table->unique('customername', 'pan', 'mobile');
现在是所有三个值的组合都是唯一的还是三个中的两个都是唯一的?
我想要的是所有三个的组合必须是唯一的。
我在上面尝试时遇到了这个错误
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'newCust' for key 'pan' (SQL: insert into `customers` (`customername`, `pan`, `customertype`, `email`, `mobile`, `offadd`, `now`, `referer_id`, `updated_at`, `created_at`) values (newCust, 1234, sasdfsdf, sdfsdf@sfdlfsdf.com, 4567, adsfasdf, sdfsdf, 2, 2014-11-23 09:47:43, 2014-11-23 09:47:43))"
完整架构
$table->increments('id');
$table->string('customername');
$table->string('pan');
$table->string('customertype');
$table->string('email');
$table->string('mobile');
$table->unique('customername', 'pan', 'mobile');
$table->text('offadd');
$table->text('comadd');
$table->string('website');
$table->string('now');
$table->string('companyname');
$table->date('dob');
$table->integer('referer_id');
$table->string('status');
$table->timestamps();
【问题讨论】: