Advertisement
citstudio

cakePHP Treeview Model

Jul 16th, 2014
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2. App::uses('AppModel', 'Model');
  3. class Histories extends AppModel {
  4.   public $useTable = 'histories';
  5.   var $displayField = 'history_name';
  6.   var $hasMany = array(
  7.       'ChildPage' =>
  8.       array('className' => 'Histories',
  9.           'foreignKey' => 'parent_id'
  10.       ),
  11.   );
  12.  
  13.   public function __getAll() {
  14.  
  15.     $q = $this->find('all', array(
  16.         'conditions' => array("Histories.parent_id " => NULL),
  17.         'recursive' => 2,
  18.         'order' => array('Histories.id' => 'asc')
  19.             ));
  20.     return $q;
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement