ChrisBull ChrisBull - 1 year ago 77
MySQL Question

Account verification in CakePHP

I am using CakePHP 3.x. I have created the code that creates a new user in the following table;


id | email | password | verification | verified | last_activity | date_created

The verified column will be a foreign key to the 'user_verification' table.

  1. Should by convention, this be named verification_id and could you confirm the names of the table etc?

The relationship is that Users hasOne verification. When the user is created another entry in the user_verification table will be created which will populate the user entry with its id.

  1. Does this seem like a logical way to get about creating a verification table? I do want them to be in separate tables.

  2. Can someone point me in the direction for accessing the verification table while inside the Users controller.


Answer Source

Yes, with CakePHP it's best to name a column verification_id if it is related to another table. This way, when you bake the model it automatically does the work for you.

You can access the verification table inside the Users controller by loading the model.


Controller (Loading Additional Models)

EDIT: According to CakePHP's documentation, you should give your table a plural name such as verifications not verification.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download