Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZendFramework] Relacje (dependent Tables), problem z findDependentRowset()
Sajrox
post
Post #1





Grupa: Zarejestrowani
Postów: 254
Pomógł: 7
Dołączył: 9.10.2007
Skąd: Poznań

Ostrzeżenie: (0%)
-----


Witam,

Otóż mam pewien kłopot z relacjami w Zend_Db.
Mam klase:

  1. class Global_Model_Users extends Db_Table_Users
  2. {
  3. public function getAll()
  4. {
  5.      // Sposób 1
  6.      // To nie działa. Dlaczego ?
  7.      //$tbl_data = parent::fetchAll();
  8.  
  9.  
  10.      // Sposób 2
  11.      // to działa
  12.      $tbl = new parent;
  13.      $tbl_data = $tbl->fetchAll();
  14.  
  15.  
  16.      foreach($tbl_data as $row) 
  17.      { 
  18.           $data[] = $row->findDependentRowset('Db_Table_Acl_Users', null)->toArray();
  19.      }
  20. }

Generalnie chodzi o to że nie mogę uzyć metody findDependentRowset() przy uzyciumetody fetchAll() w 1 sposobie.
Dostaje wtedy

  1. Error: No reference from table Db_Table_Acl_Users to table Global_Model_Users


Mimo tego że mam referencję ustawione.
  1. class Db_Table_Users extends Zend_Db_Table_Abstract
  2. {
  3. public $_name = 'users';
  4. public $_dependentTables = array('Db_Table_Acl_Users');
  5. }



  1. class Db_Table_Acl_Users extends Zend_Db_Table_Abstract
  2. {
  3.   protected $_name = 'users_acl';
  4. protected $_primary = 'users_id';
  5. protected $_referenceMap = array(
  6. 'Db_Table_Users' => array(
  7. 'columns' => array('users_id'),
  8. 'refTableClass' => 'Db_Table_Users',
  9. 'refColumns' => array('id')
  10. )
  11. );
  12. }


Czym się różni:
new parent od parent::


Go to the top of the page
+Quote Post
seth-kk
post
Post #2





Grupa: Zarejestrowani
Postów: 444
Pomógł: 79
Dołączył: 26.05.2009

Ostrzeżenie: (0%)
-----


new parent - tworzy instancje klasy bazowej
parent::foo() - odwoluje sie do metody zdefiniowanej w klasie bazowej
Co do referencji to ma ja one miejsce na poziomie modeli a nie tabel - w referenceMap podajesz z jakimi modelami (klasami) powiazany jest dany model
jak dodasz Global_Model_Users do referenceMap zacznie dzialac


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 11:36