php - 键“PRIMARY”的重复条目“制造商名称-0”
问题描述
我充其量是一个中间人,我们将不胜感激。我正在尝试上传包含药物、制造商、通用名称等数据库的 csv 文件。
我将它用于 .php
$this->db->insert('acc_coa',$manufacturer_coa); }
$check_category = $this->db->select('*')->from('product_category')->where('category_name',$insert_csv['category_id'])->get()->row();
if(!empty($check_category)){
$category_id = $check_category->category_id;
}else{
$categorydata=array(
'category_name' => $insert_csv['category_id'],
'status' => 1
);
if ($count > 0) {
$this->db->insert('product_category',$categorydata);
}
这对于数据库:
CREATE TABLE acc_coa
(
HeadCode
varchar(50) COLLATE utf8_unicode_ci NOT NULL,
HeadName
varchar(100) COLLATE utf8_unicode_ci NOT NULL AUTO_INCREMENT,
PHeadName
varchar(50) COLLATE utf8_unicode_ci NOT NULL,
HeadLevel
int(11) NOT NULL,
IsActive
tinyint(1) NOT NULL,
IsTransaction
tinyint(1) NOT NULL,
customer_id
int(11) DEFAULT NULL,
manufacturer_id
int(11) DEFAULT NULL,
IsGL
tinyint(1) NOT NULL,
HeadType
char(1) COLLATE utf8_unicode_ci NOT NULL,
IsBudget
tinyint(1) NOT NULL,
IsDepreciation
tinyint(1) NOT NULL,
DepreciationRate
decimal(18, 2)非空,
CreateBy
varchar(50)整理utf8_unicode_ci非空,
CreateDate
日期时间非空,
UpdateBy
varchar(50)整理utf8_unicode_ci非空,
UpdateDate
日期时间非空,主键(HeadName
) ) 引擎=InnoDB 默认字符集=utf8 COLLATE=utf8_unicode_ci;
但是任何时候我尝试我都会得到这个
错误号:1062
键“PRIMARY”的重复条目“制造商名称-0”
插入acc_coa
( HeadCode
, HeadName
, PHeadName
, HeadLevel
, IsActive
, IsTransaction
, IsGL
, HeadType
, IsBudget
, manufacturer_id
, IsDepreciation
, DepreciationRate
, CreateBy
, CreateDate
) 值 ('502020000001', '制造商名称-0', '应付帐款', '3', '1', '1', '0' , 'L', '0', 0, '0', '0', '1', '2021-05-27 18:15:47')
文件名:C:/wamp64/www/efkwa/system/database/DB_driver.php
行号:691
解决方案
此错误表明您已经输入了具有该值的示例/行(制造商名称-0),主键充当每个示例的唯一标识符,因此不能在表的其他示例/行中重复
推荐阅读
- flutter - 处置后返回未来
- node.js - NextJs api在第一次加载时路由空响应
- python-3.x - Python 类型:别名 vs NewType 最佳实践?
- php - 如何覆盖 presta Shop 捆绑产品控制器
- c# - 从 MongoDB 队列写入的信号量实现
- reactjs - 如何将来自反应路由器 dom 的链接放在 Material UI 表中
- pine-script - pinescript 上较低 TF 的变量
- r - 有没有办法直接将 rmarkdown 渲染到对象而不保存到磁盘?
- c# - 如何在浏览器主窗口顶部显示 HTTP 响应状态代码和网页标题 C# web browser from this code
- html - 我无法在输入元素中写入