Ziskanie nechcenych vysledkov
- orion05
- Člen | 9
Zdravim,
v Nette som zaciatocnikom, podla precitanych tem som spojazdnil JOIN dvoch tabuliek v Nette/Database, no mam problem ze dostavam vysledky ktore nechcem.
Mam tabulky geocaching a geocaching_countries. Z geocaching_countries chcem ziskat stlpec image a pridat ho k vysledkom z tabulky geocaching.
Problem je ten, ze ako vysledok dostanem 2 riadky podla poctu riadkov v tabulke geocaching_countries a ku kazdej krajine jeden riadok z prvej tabulky aj napriek tomu ze sql prikaz v debuggeri ukazuje spravny prikaz a vykona sa spravne, teda ako keby som dostal vysledky zgrupene podla krajiny.
Prikladam zdrojove kody:
Model:
public function fetchBy($type=NULL,$country=NULL,$region=NULL,$district=NULL,$town=NULL)
{
$table = $this->connection->table($this->tableName);
$table->select('*,geocaching_countries.image');
/*if(isset($type))
$table->where('type',$type);
if(isset($country))
$table->where('country',$country);
if(isset($region))
$table->where('region',$region);
if(isset($district))
$table->where('district',$region);
if(isset($town))
$table->where('town',$town);
*/
dump($table->fetchAll());
//return $table->fetchAll();
}
SQL kód z debuggeru
SELECT *,`geocaching_countries`.`image`
FROM `geocaching`
LEFT JOIN `geocaching_countries` ON `geocaching`.`geocaching_countries_id` =
`geocaching_countries`.`id`
Dufam, ze otazka bude pochopena a vopred dakujem za odozvy k rieseniu problemu
Editoval orion05 (13. 5. 2014 21:26)