douxiangshi6568 2012-06-02 05:51
浏览 48
已采纳

用户ID与cakephp中的user_id不匹配

I have a table named user. The id is generated on the fly.

I have a HABTM table. I am trying to insert a record during the user registration. For some reason I can't get the user's id and the user_id to match.

This looks correct, even my array reflects the right information, but the actual data stored is not right.

code:

$this->request->data['User']['id'] = String::uuid();
$this->request->data['Company']['Company'][0]['user_id'] = $this->request->data['User']['id'];

returned array:

Array
(
[User] => Array
    (
        [email_address] => asdf@asdf.com
        [id] => 4fc9a939-3e24-4c79-85d1-6c28e4ca782d
    )

[Company] => Array
    (
        [Company] => Array
            (
                [0] => Array
                    (
                        [id] => 4fc9a939-1840-4c1b-8bd2-6c28e4ca782d
                        [company_id] => 4fc990dd-edb0-4559-bb7b-6a00e4ca782d
                        [user_id] => 4fc9a939-3e24-4c79-85d1-6c28e4ca782d
                    )

            )

    )

)

So it appears that it would work based on the array I got, but it doesn't save like that. Help is much appreciated.

  • 写回答

1条回答 默认 最新

  • dtiu94034 2012-06-02 06:57
    关注

    Maybe because cake autogenerates id to UUID (when field is string and length is 36) take a look at CakePHP API - Model->save()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?