06.30 php saved
voycey-HABTMSelfReferential
Tags add more
HABTM Self Referenti  
Note
voycey-HABTMSelfReferential did not leave a note
  1. <?php
  2. class User extends AppModel {
  3.  
  4.     var $name = 'User';
  5.  
  6.     //The Associations below have been created with all possible keys, those that are not needed can be removed
  7.     var $belongsTo = array(
  8.             'Group' => array('className' => 'Group',
  9.                                 'foreignKey' => 'group_id',
  10.                                 'conditions' => '',
  11.                                 'fields' => '',
  12.                                 'order' => ''
  13.             )
  14.     );
  15.  
  16.     var $hasOne = array(
  17.             'AdditionalHarmony' => array('className' => 'AdditionalHarmony',
  18.                                 'foreignKey' => 'user_id',
  19.                                 'dependent' => false,
  20.                                 'conditions' => '',
  21.                                 'fields' => '',
  22.                                 'order' => ''
  23.             ),
  24.             'Harmony' => array('className' => 'Harmony',
  25.                                 'foreignKey' => 'user_id',
  26.                                 'dependent' => false,
  27.                                 'conditions' => '',
  28.                                 'fields' => '',
  29.                                 'order' => ''
  30.             ),
  31.             'HarmonyInvite' => array('className' => 'HarmonyInvite',
  32.                                 'foreignKey' => 'user_id',
  33.                                 'dependent' => false,
  34.                                 'conditions' => '',
  35.                                 'fields' => '',
  36.                                 'order' => ''
  37.             ),
  38.             'Post' => array('className' => 'Post',
  39.                                 'foreignKey' => 'user_id',
  40.                                 'dependent' => false,
  41.                                 'conditions' => '',
  42.                                 'fields' => '',
  43.                                 'order' => ''
  44.             ),
  45.             'SongList' => array('className' => 'SongList',
  46.                                 'foreignKey' => 'user_id',
  47.                                 'dependent' => false,
  48.                                 'conditions' => '',
  49.                                 'fields' => '',
  50.                                 'order' => ''
  51.             ),
  52.             'Track' => array('className' => 'Track',
  53.                                 'foreignKey' => 'user_id',
  54.                                 'dependent' => false,
  55.                                 'conditions' => '',
  56.                                 'fields' => '',
  57.                                 'order' => ''
  58.             ),
  59.             'UserAlbum' => array('className' => 'UserAlbum',
  60.                                 'foreignKey' => 'user_id',
  61.                                 'dependent' => false,
  62.                                 'conditions' => '',
  63.                                 'fields' => '',
  64.                                 'order' => ''
  65.             ),
  66.             'UserDuet' => array('className' => 'UserDuet',
  67.                                 'foreignKey' => 'user_id',
  68.                                 'dependent' => false,
  69.                                 'conditions' => '',
  70.                                 'fields' => '',
  71.                                 'order' => ''
  72.             ),
  73.             'UserProfile' => array('className' => 'UserProfile',
  74.                                 'foreignKey' => 'user_id',
  75.                                 'dependent' => false,
  76.                                 'conditions' => '',
  77.                                 'fields' => '',
  78.                                 'order' => ''
  79.             ),
  80.             'Vote' => array('className' => 'Vote',
  81.                                 'foreignKey' => 'user_id',
  82.                                 'dependent' => false,
  83.                                 'conditions' => '',
  84.                                 'fields' => '',
  85.                                 'order' => ''
  86.             )
  87.     );
  88.  
  89.     var $hasMany = array(
  90.             'AdditionalHarmony' => array('className' => 'AdditionalHarmony',
  91.                                 'foreignKey' => 'user_id',
  92.                                 'dependent' => false,
  93.                                 'conditions' => '',
  94.                                 'fields' => '',
  95.                                 'order' => '',
  96.                                 'limit' => '',
  97.                                 'offset' => '',
  98.                                 'exclusive' => '',
  99.                                 'finderQuery' => '',
  100.                                 'counterQuery' => ''
  101.             ),
  102.             'Harmony' => array('className' => 'Harmony',
  103.                                 'foreignKey' => 'user_id',
  104.                                 'dependent' => false,
  105.                                 'conditions' => '',
  106.                                 'fields' => '',
  107.                                 'order' => '',
  108.                                 'limit' => '',
  109.                                 'offset' => '',
  110.                                 'exclusive' => '',
  111.                                 'finderQuery' => '',
  112.                                 'counterQuery' => ''
  113.             ),
  114.             'HarmonyInvite' => array('className' => 'HarmonyInvite',
  115.                                 'foreignKey' => 'user_id',
  116.                                 'dependent' => false,
  117.                                 'conditions' => '',
  118.                                 'fields' => '',
  119.                                 'order' => '',
  120.                                 'limit' => '',
  121.                                 'offset' => '',
  122.                                 'exclusive' => '',
  123.                                 'finderQuery' => '',
  124.                                 'counterQuery' => ''
  125.             ),
  126.             'Post' => array('className' => 'Post',
  127.                                 'foreignKey' => 'user_id',
  128.                                 'dependent' => false,
  129.                                 'conditions' => '',
  130.                                 'fields' => '',
  131.                                 'order' => '',
  132.                                 'limit' => '',
  133.                                 'offset' => '',
  134.                                 'exclusive' => '',
  135.                                 'finderQuery' => '',
  136.                                 'counterQuery' => ''
  137.             ),
  138.             'SongList' => array('className' => 'SongList',
  139.                                 'foreignKey' => 'user_id',
  140.                                 'dependent' => false,
  141.                                 'conditions' => '',
  142.                                 'fields' => '',
  143.                                 'order' => '',
  144.                                 'limit' => '',
  145.                                 'offset' => '',
  146.                                 'exclusive' => '',
  147.                                 'finderQuery' => '',
  148.                                 'counterQuery' => ''
  149.             ),
  150.             'Track' => array('className' => 'Track',
  151.                                 'foreignKey' => 'user_id',
  152.                                 'dependent' => false,
  153.                                 'conditions' => '',
  154.                                 'fields' => '',
  155.                                 'order' => '',
  156.                                 'limit' => '',
  157.                                 'offset' => '',
  158.                                 'exclusive' => '',
  159.                                 'finderQuery' => '',
  160.                                 'counterQuery' => ''
  161.             ),
  162.             'UserAlbum' => array('className' => 'UserAlbum',
  163.                                 'foreignKey' => 'user_id',
  164.                                 'dependent' => false,
  165.                                 'conditions' => '',
  166.                                 'fields' => '',
  167.                                 'order' => '',
  168.                                 'limit' => '',
  169.                                 'offset' => '',
  170.                                 'exclusive' => '',
  171.                                 'finderQuery' => '',
  172.                                 'counterQuery' => ''
  173.             ),
  174.             'UserDuet' => array('className' => 'UserDuet',
  175.                                 'foreignKey' => 'user_id',
  176.                                 'dependent' => false,
  177.                                 'conditions' => '',
  178.                                 'fields' => '',
  179.                                 'order' => '',
  180.                                 'limit' => '',
  181.                                 'offset' => '',
  182.                                 'exclusive' => '',
  183.                                 'finderQuery' => '',
  184.                                 'counterQuery' => ''
  185.             ),
  186.            
  187.             'UserProfile' => array('className' => 'UserProfile',
  188.                                 'foreignKey' => 'user_id',
  189.                                 'dependent' => false,
  190.                                 'conditions' => '',
  191.                                 'fields' => '',
  192.                                 'order' => '',
  193.                                 'limit' => '',
  194.                                 'offset' => '',
  195.                                 'exclusive' => '',
  196.                                 'finderQuery' => '',
  197.                                 'counterQuery' => ''
  198.             ),
  199.             'UserTrack' => array('className' => 'UserTrack',
  200.                                 'foreignKey' => 'user_id',
  201.                                 'dependent' => false,
  202.                                 'conditions' => '',
  203.                                 'fields' => '',
  204.                                 'order' => '',
  205.                                 'limit' => '',
  206.                                 'offset' => '',
  207.                                 'exclusive' => '',
  208.                                 'finderQuery' => '',
  209.                                 'counterQuery' => ''
  210.             ),
  211.             'Vote' => array('className' => 'Vote',
  212.                                 'foreignKey' => 'user_id',
  213.                                 'dependent' => false,
  214.                                 'conditions' => '',
  215.                                 'fields' => '',
  216.                                 'order' => '',
  217.                                 'limit' => '',
  218.                                 'offset' => '',
  219.                                 'exclusive' => '',
  220.                                 'finderQuery' => '',
  221.                                 'counterQuery' => ''
  222.             )
  223.     );
  224.  
  225.     var $hasAndBelongsToMany = array(
  226.             'Group' => array('className' => 'Group',
  227.                         'joinTable' => 'groups_users',
  228.                         'foreignKey' => 'user_id',
  229.                         'associationForeignKey' => 'group_id',
  230.                         'unique' => true,
  231.                         'conditions' => '',
  232.                         'fields' => '',
  233.                         'order' => '',
  234.                         'limit' => '',
  235.                         'offset' => '',
  236.                         'finderQuery' => '',
  237.                         'deleteQuery' => '',
  238.                         'insertQuery' => ''
  239.             ),
  240.              'Friend' => array('className' => 'User',
  241.                         'joinTable' => 'users_users',
  242.                         'foreignKey' => 'user_id',
  243.                         'associationForeignKey' => 'friend_id',
  244.                         'unique' => true,
  245.                         'conditions' => '',
  246.                         'fields' => '',
  247.                         'order' => '',
  248.                         'limit' => '',
  249.                         'offset' => '',
  250.                         'finderQuery' => '',
  251.                         'deleteQuery' => '',
  252.                         'insertQuery' => ''
  253.             )
  254.     );
  255.    
  256.     function getIdByName($name) {
  257.         $data = $this->find('all', array(
  258.             'conditions' => array('username' => $name )));
  259.         return $data['User']['id'];
  260.     }
  261. }
  262. ?>
Parsed in 0.757 seconds, using GeSHi 1.0.7.14

Modify this Paste