Results 1 to 5 of 5

Thread: Links between models in CakePHP

  1. #1
    Join Date
    Sep 2010
    Posts
    19

    Links between models in CakePHP

    This is the result of my adventures with relations between models:
    I have 3 tables, groups, rights and application_modules linked by a table that contains id application_modules_groups_rights the 3 tables foreign keys and id own (because cake does not support composite primary keys). My question is: how to make this ternary relationship (is that right word?) in my models? HABTM with, but I guess I do not know how to report them. I am expecting some help from your side.

  2. #2
    Join Date
    Feb 2010
    Posts
    184

    Re: Links between models in CakePHP

    Actually no beginner (I move the discussion) and mostly impossible to do simply with Cake ... No ternary relationship, or quaternary, simply. You have to find another model. By cons, small precision that can be useful: even if Cake did not "bear" made by PK, as long as you do not need to query the table directly binding, no worries. I have dozens of tables reported association with a PK on two columns and everything works impeccable. I think that you should have considered managing rights with acl but they must be configurable for a non-admin computer, which will in any event no access to sources, is that possible?

  3. #3
    Join Date
    Feb 2010
    Posts
    207

    Re: Links between models in CakePHP

    Since there is already a post for relations I like a little word of explanation. So I have a table 'Admins' (id, role_id, no first name, login, password) and a table roles (id, role) [role = admin or super admin]. Grant me my logic tells me an admin has a role (admin role hasOne) and a role appratient an admin (admin role belongsTo).
    PHP Code:
    Code
      class 
    Admin extends AppModel {
         var $ 
    name 'Admin';                
         var $ 
    hasOne 'Role';   
     } 
    But when adding an admin, cake did not want this relationship so I reversed (I put in the hasOne and belongsTo role in admin) and it was willing?

  4. #4
    Join Date
    Apr 2009
    Posts
    55

    Re: Links between models in CakePHP

    Groups that I manage are unfortunately not inherited, and a user group can have similar permissions to another group (and to be avoided at all costs to manage rights at the user), I So much needs to place a user in several groups potentially. As the admin who will manage these rights to know the roles and groups, all the resources, I do not see how that will be aware. Not to mention that I do not support the connection phase, which depends on external application to my project. And my former project leader was perhaps not an expert in SQL but instead used very questionable behavior of mysql (which I use in this case) with a large number of data.

  5. #5
    Join Date
    Dec 2008
    Posts
    69

    Re: Links between models in CakePHP

    Yes it is not easy, but it can be done without problem. The solution is not to attach a User in multiple groups, but it attached to a main group and then assign specific rights that may be those of one or more other groups. At worst create additional groups containing the properties of several groups ... You can make a script that automatically updates your tables AROs, ACOs and AROs_ACOs ... but if the admins who manage do not know what rights they manage, is tricky, no? Suspicious behavior of MySQL? With old versions can be, but I doubt that PK is composed originally of these behaviors ... and now, MySQL is very robust, even with large amounts of data. I do not see what brings as "security" means to add a PK artificial ... Also I would like to suggest you not to respect the relational model and standard SQL or grind for "artificially" what we want!.

Similar Threads

  1. CakePHP vs. Ruby on Rails
    By pele1200 in forum Polls & Voting
    Replies: 9
    Last Post: 03-08-2012, 05:26 PM
  2. How to get id of another model in CakePHP?
    By Iker in forum Software Development
    Replies: 4
    Last Post: 05-01-2011, 04:48 AM
  3. Need help with a project in CakePHP
    By Ander K in forum Software Development
    Replies: 4
    Last Post: 05-01-2011, 12:09 AM
  4. What are basic Principles of CakePHP?
    By Xanty in forum Software Development
    Replies: 6
    Last Post: 04-01-2011, 11:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,799,223.18385 seconds with 17 queries