Sunday, 15 March 2015

php - Phalcon model relationships ..ToMany() not working -


I have tried to establish relationships between groups of users and users using various methods through Users_Group Nothing works with the name, hasManyToMany and hasMany etc. and nothing gives me an error: Fatal error: Class 'Users_Groups' is not found ... Here is my UserController part: < / P>

  public function registerAction () {$ user = new user (); $ Password = $ it- & gt; Security-> Hash ($ this-> request-> getPost ('password')); $ Signup = array ('name' = & gt; $ this-> request- & gt; getPost ('name'), 'username' = & gt; $ the-> request- & gt; getPost ('Username'), 'email' = & gt; $ - this- & gt; request- & gt; getPost ('email'), 'password' = & gt; $ password, 'active' = & gt; Y ',' datetime '= & gt; date (' Ymd's time ())); // Store and check errors $ success = $ user- & gt; Save ($ signup, array ('name', 'username', 'email', 'password', 'active', 'date time')); $ Group = group :: findByName ('user'); $ UserGroup = new Users_Groups (); $ UserGroup- & gt; User_id = $ user- & gt; GetId (); $ UserGroup- & gt; Group_ id = $ group- & gt; GetId (); $ GroupSuccess = $ userGroup- & gt; Save (); If ($ success and group group success) {resonant "Thanks for registering!"; } Else {echo "Sorry, the following problems occurred:"; Forex Currency ($ user-> getMessages () as $ message) {echo $ message-> GetMessage (), "& lt; br / & gt;"; }} $ This-> View- & gt; Disable (); }  

Here is a user model:

  Start Public Function () {$ this-> Hind ('id', 'users_groups', 'user_id'); $ This- & gt; HasMany ('id', 'QSOs', 'user_id'); $ This- & gt; HasMany ('id', 'config', 'user_id'); }  

This group model is:

  public function start () {$ this-> Hamind ('id', 'user_group', 'group_id'); }  

and finally user_group model

  start public function () {$ this-> Affiliate ('user_id', 'users', 'id'); $ This- & gt; BelongsTo ('group_id', 'group', 'id'); }  

Please help! It drives me crazy!


No comments:

Post a Comment