Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. class Model_Language extends ORM
  2. {
  3.  
  4. protected $_has_many = array( 'supercategories' => array(
  5. 'model' => 'supercategory',
  6. 'foreign_key'=>'language_id',
  7. ));
  8.  
  9. }
  10.  
  11. class Model_Supercategory extends ORM
  12. {
  13. protected $_table_name = "supercategories";
  14.  
  15. protected $_belongs_to = array('language' => array());
  16.  
  17. protected $_has_many = array('category' => array());
  18.  
  19.  
  20. }
  21.  
  22. $language = ORM::factory('language');
  23.  
  24. $res = $language->supercategories->find_all();
  25. foreach ($res as $item) {
  26. echo $item->name;
  27. }
  28.  
  29. object Database_MySQL_Result(7) {
  30. protected _internal_row => integer 0
  31. protected _query => string(559) "SELECT `supercategory`.`id` AS `id`, `supercategory`.`name` AS `name`, `supercategory`.`url` AS `url`, `supercategory`.`description` AS `description`, `supercategory`.`language_id` AS `language_id`, `supercategory`.`position` AS `position`, `supercategory`.`aspage` AS `aspage`, `supercategory`.`content` AS `content`, `supercategory`.`showcomments` AS `showcomments`, `supercategory`.`show` AS `show`, `supercategory`.`author` AS `author`, `supercategory`.`date` AS `date` FROM `supercategories` AS `supercategory` WHERE `supercategory`.`language_id` IS NULL"
  32. protected _result => resource(mysql result)
  33. protected _total_rows => integer 0
  34. protected _current_row => integer 0
  35. protected _as_object => string(19) "Model_Supercategory"
  36. protected _object_params => NULL
  37. }
  38.  
  39. $language = ORM::factory('language',array('id','1'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement