How to save hasOne relationship



i tried association table users and table profiles with hasone ,
and idont know how to insert or saving data , value id form table users same with value user_id form table profiles… :frowning:


Check if you can retrieve data with associations. If you can, try edit them and save with simply $this->yourModel->save($entity)


thank you jarekgol , its my case , descriptions ,
"thank, so i tried Association hasone on cakephp 3.4 , i dont know , but i cannot displayed data and cannot automatically update user_id , on my profiles table , …
this my code and conditions my table,"
i want association my users table and my profiles table.
this line my userstable.php

and my profilestable.php


the is no user_id column in your profile table.

you set your hasOne foreignKey to no_hp column, which is no_hp is varchar column.

so you need to change it to something like this :

in your UsersTable.php


and add user_id column to your profiles table

refer here for more details :


Boommmmm, I got itssssssssss, hahahaha , I amm vey happy , thank all … Just Change $datakartu->Profiles->nama to $datakartu->profile->nama ;


before I apologize about the title of my post, for the user_id column automatically value I do not worry because it can give its value manually and i changed foreign key from user_id to no_hp … sorry all…


Hi wakikuk. Can you share the sourcecode?