如何使用fat-free ORM只向id table插入数据?

How to use fat-free ORM to insert data to id only table?

我有这个table

CREATE TABLE IF NOT EXISTS `group` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `id_UNIQUE` (`id` ASC))
ENGINE = InnoDB;

这是工作。

INSERT INTO `group` (`id`) VALUES (NULL);

但是我无法使用 fat-free 插入记录

我试过了。

$group=new DB\SQL\Mapper($f3->get('DB'),'group');
$group->save();

还有这个。

$group=new DB\SQL\Mapper($f3->get('DB'),'group');
$group->id=null;
$group->save();

还有这个。

$group=new DB\SQL\Mapper($f3->get('DB'),'group');
$group->id='null';
$group->save();

但是没有人可以创建记录,也没有错误。

向此 table 插入记录的正确方法是什么?

Fat-Free Framework 的 Mapper 不会 insert 除了主键之外没有 (changed/new) 值的记录。所以 $fields 数组是空的,Mapper 跳过 insert operation.

我不确定这是否符合 bug

这是一个基于您提供的查询和 F3 的 SQL 对象的简单解决方案:

$sql = $f3->get('DB');
$sql->exec('INSERT INTO group (id) VALUES (NULL)');