SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. resources:
  2.  
  3.   MySQL Table                           CakePHP Model Association
  4.  
  5.     +----------+-------------+          class Resource extends AppModel {
  6.     | Field    | Type        |              var $name = 'Resource';
  7.     +----------+-------------+              var $primaryKey = 'id';
  8.     | id       | int(11)     |              var $hasAndBelongsToMany = array('Media');
  9.     | user_id  | int(11)     |          }
  10.     | uuid     | varchar(15) |          
  11.     +----------+-------------+          
  12.  
  13.   media:
  14.  
  15.     MySQL Table                         CakePHP Model Association
  16.  
  17.     +-----------------+-------------+   class Media extends AppModel {
  18.     | Field           | Type        |       var $name = 'Media';
  19.     +-----------------+-------------+       var $primaryKey = 'id';
  20.     | id              | int(11)     |       var $hasAndBelongsToMany = array('Resource');
  21.     | type            | varchar(50) |   }
  22.     | uri             | varchar(255)|
  23.     | created         | datetime    |
  24.     +-----------------+-------------+
  25.  
  26.   media_resources:
  27.  
  28.     MySQL Table                         CakePHP Model Association
  29.  
  30.     +-------------+---------+           class MediaResource extends AppModel {
  31.     | Field       | Type    |               var $name = 'MediaResource';
  32.     +-------------+---------+               var $primaryKey = 'id';
  33.     | id          | int(11) |           }
  34.     | resource_id | int(11) |
  35.     | media_id    | int(11) |
  36.     +-------------+---------+
  37.    
  38. $this->Resource-find('All','conditions'=>array( 'Resource.id' => 2 );
  39.    
  40. Array(
  41.     [Resource] => Array(
  42.         //Resource Data
  43.     )
  44.     [Media] => Array(
  45.         [0] => Array(
  46.             //Media Data
  47.         )
  48.         [1] => Array(
  49.             //Media Data
  50.         )
  51.         ///... etc.
  52.     )
  53. )
  54.    
  55. Array(
  56.     [Resource] => Array(
  57.         //Resource Data
  58.     )
  59.     [Media] => Array(
  60.         //Media Data
  61.     )
  62. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top