Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework]Problem z łączeniem tabel
kardi3
post
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 17.07.2011

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


Witam,
męcze się już któryś dzień z łączeniem tabel, przeczytałem mnóstwo postów i sposobów a rozwiązania dalej nie znalazłem

Mam 2 tabele
CODE
cars
idcar
brand
model

pricelist
idcar
rentprice
perkmprice



Chcę zrobić zapytanie :
CODE
select brand, model, rentprice from cars c inner join pricelist p on c.idcar=p.idcar



Oto moje pliki :
CODE

model
<?php

class Application_Model_Cars extends Zend_Db_Table_Abstract
{
protected $_name = 'cars';

public function pobierzDane() {

$table = new Application_Model_Cars();
$resultSet = $table->select()
->setIntegrityCheck(false)
->from('pricelist')
->join('cars', 'cars.idcar = pricelist.idcar',array('brand','model'));
$row = $table->fetchAll($resultSet);
return $row;
}



controller
public function carTestAction()
{
$modelCars = new Application_Model_Cars();
$modelCars->pobierzDane();
$this->view->modelCars = $modelCars->fetchAll();
}


widok
<table>
<?php foreach($this->modelCars as $album) : ?>
<tr>
<td>Model</td>
<td>Cena za km</td>
</tr>
<tr>
<td><?php echo $this->escape($album->brand);?></td>
<td><?php echo $this->escape($album->perkmprice);?></td>
</tr>
<?php endforeach; ?>
</table>




Wyskakuje mi następujący komunikat

CODE
Message: Specified column "perkmprice" is not in the row


Wszystko ma chyba związek z linijką
CODE
protected $_name = 'cars';

Gdy zmieniam w niej nazwe tabeli na pricelist wtedy jakby zend nie widział 2 tabeli, wyświetla się :

CODE
Message: Specified column "brand" is not in the row


Proszę o pomoc
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 25.08.2025 - 11:21