webman/think-orm 模型的 create 方法新增数据不会返回主键的值

jorke007

@walkor webman/think-orm 这个库是封装的 thinkorm 但是tp模型的 create 方法新增数据会返回主键的值
$res = model::create($data) $res里面应该是有主键的值的
而你封装的 webman/think-orm $res里面的主键永远=0,这是个bug么
我的主键不是默认的id 可是我在模型文件里定义了 protected $pk = "order_id"; 类似这种

108 2 0
2个回答

webman/think-orm 只是在topthink/think-orm的基础上添加了协程和连接池,不影响orm本身的功能。
你的问题有可能是数据库里没把order_id设为主键或者没自增吧。

  • jorke007 5天前

    不可能的啊 order_id 有的 并设置自增 主键了的

ichynul

看看是不是使用了think-orm v4 吧

×
🔝