PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 9, 2022

[FIXED] Account verification in CakePHP

 March 09, 2022     cakephp-3.0, mysql, php     No comments   

Issue

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

users

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.

Thanks!


Solution

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.

$this->loadModel('Verification');

Controller (Loading Additional Models)

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



Answered By - user5236938
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing