DB::insert()运行一直返回的true


DROP TABLE IF EXISTS `tb_group`;
CREATE TABLE `tb_group`  (
  `group_num` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_name` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `group_user_cnt` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '人数',
  `created_date` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_date` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`group_num`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '分组' ROW_FORMAT = Compact;

SET FOREIGN_KEY_CHECKS = 1;
当aaaa不存在时,可以插入返回true,当aaaa存在时,没有新插入数据,但是返回的还是true.
在navcat中不存在返回影响行数1,存在时返回影响行数0
这是运行的sql语句
$sql = "INSERT INTO tb_group (group_name,group_user_cnt)
SELECT 'aaaa','0'
FROM DUAL
WHERE NOT EXISTS (
SELECT group_name FROM tb_group WHERE group_name = 'aaaa'
)";
$row = DB::insert($sql);
dump($row);
问题点就在于插入成功失败都返回的true,是什么原因造成的

Vote Vote Cancel Collect Collect Cancel

<< 上一篇: laravel的安装包太大,有没有精简版

>> 下一篇: 我发布了一篇文章, 发布时间貌似 emmm.... 有点久远,哈哈哈哈