Object of class Nette\Database\Table\Selection could not be converted to string

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
mordare
Začátečník | 117
+
0
-

Dobrý chtěl bych požádat o radu. Přepisuju jistý gallery modul z dibi do Nette database. a narazil sem na chybu se kterou si nevím rady. zde dávám ukázku kódu kde mi to hází u cyklu foreach chybu:
Object of class Nette\Database\Table\Selection could not be converted to string

	$data = self::$_conn->table('galerie')
		->select(self::$_conn->table('dgalerie')->select('dgalerie.id')
			->where('galerie.id = dgalerie.galerie'))
		->order('title');
/*$data = \dibi::select('*')
                ->select(
                        \dibi::select('count(dgalerie.id)')
                        ->from('dgalerie')
                        ->where(('g.id = dgalerie.galerie'))
                )->as('photos')
                ->from('galerie')->as('g')->orderBy('title')->fetchAll();*/
foreach ($data as $g) {
    $g = new GalleryNoImages($g);
}
JuniorJR
Člen | 181
+
0
-
...->fetchAll();
mordare
Začátečník | 117
+
0
-

Call to undefined method Nette\Database\Table\Selection::fetchAll()

jansfabik
Člen | 193
+
0
-

fetchAll() určitě ne, nic takového Nette\Database nemá. Na jakém řádku to hází chybu? Nemohl bys ukázat laděnku?

Caine
Člen | 216
+
0
-

Ze selection (ta subquery) si to neumi samo udelat string, ale muzes pres ->getSql (ale mam dojem, ze to je az v pozdejsich verzich nette)

self::$_conn->table('dgalerie')->select('dgalerie.id')
        ->where('galerie.id = dgalerie.galerie')->getSql() //ps nikde tu nevidim ten count, ktery mas u toho dibi:)

Kazdopadne, asi bych to prepsal spis na:

$data = self::$_conn->table('galerie')
->select('*')
->select('COUNT(dgalerie:id) AS photos') //samo vytvori join podle zvolene db reflection
->order('title');

Editoval Caine (7. 10. 2012 13:20)

mordare
Začátečník | 117
+
0
-

mno to už vypadá o něco lépe díky, ale má to asi nějaký problém s tím as photos jelikož laděnka mi vrací

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`photos` FROM `galerie` LEFT JOIN `dgalerie` ON `galerie`.`id` = `dgalerie`.`gal'
Caine
Člen | 216
+
0
-

To AS musi byt velkym pismem, jak to asi vyescapuje

mordare
Začátečník | 117
+
0
-

díky. už to jede ;)