Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zend baza danych join
cykcykacz
post 16.01.2012, 19:53:39
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

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


Witam,
mam dwie tabele:
articles:
i_id,
i_name,
i_text

druga tabela:
users
id,
username,
password,
first_name,
last_name,
role

Robięto w ten sposób:
Model:
  1. <?php
  2. class Model_Select extends Zend_Db_Table_Abstract
  3. {
  4. protected $_name = 'articles';
  5. protected $_primary = 'i_id';
  6.  
  7. public function join()
  8. {
  9. $select = $this->select()
  10. ->from(array('a' => 'articles'),
  11. array('i_id','i_name'))
  12. ->join(array('u' => 'users'),
  13. 'a.i_id = u.id',
  14. array('username') );
  15.  
  16. return $this->fetchAll($select);
  17. }
  18.  
  19.  
  20. }

kotroler
  1. public function joinAction()
  2. {
  3. // action body
  4. $modelselect = new Model_Select();
  5. //$modelselect->setIntegrityCheck(false);
  6. $this->view->select = $modelselect->join();
  7. }

widok
Kod
    <?php foreach($this->select as $row): ?>
            <table class="table1">
        <tr><td colspan="2" class="title"><strong class="red">ID:</strong><?php echo $row->i_id ?></td></tr>
            <tr><td><strong class="blue">Tytuł:</strong></td><td><?php echo $row->i_name ?></td></tr>
    </table>
    <?php endforeach ?>


Dostaję taki komunikat błędu:
Kod
Exception information:

Message: Select query cannot join with another table
Go to the top of the page
+Quote Post

Posty w temacie


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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 15:01