douzhiba6873 2014-08-20 18:28
浏览 9

在另一个控制器中向另一个数据库表添加值是添加新项

After saving data from the chats controller to the chat model, I want to add the last id of this chat item to another database table called issues. I do this from the ChatsController:

        // Get last inserted id from Chat
        $lastid = $this->Chat->getLastInsertId();
        // Set the issue id to be updated
        $this->Chat->Issue->id = $issueid;
        // Update Issue table
        $this->Chat->Issue->saveField('chat_id', $lastid);

Where I want to update Issue database item with id $issueid and add $lastid to field Issue.chat_id. $issueid is set before and is present and I am assuming $lastid is also set.

In both the issue and chat model, the models are belonging to the other.

What am I doing wrong that a new line is inserted in the issue database table instead of updating the correct one?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?