Databáze explorer – alias tabulky

Allconius
Člen | 313
+
0
-

Ahoj, nevím jak přepsat tento sql dotaz:

<?php
$dotaz = '
SELECT
t2.* from $tabulka as t1,
$tabulka as t2
WHERE
t1.ms=1 and
t1.smazano=0 and
t1.detas=t2.id and
t2.smazano=0 and
t2.detas=0 and
t2.kod<>1
GROUP BY
t2.id
ORDER BY t2.ulice';
?>

do formátu database explorer:

<?php
$result = $this->database->table($this->tabulka)
                    ->where(''.$this->tabulka.'.ms = ?', 1)
                    ->where(''.$this->tabulka.'.smazano = ?', 0)
                    ->where(''.$this->tabulka.'.detas = ?', ''.$this->tabulka.'.id')
                    ...... ????? ;
?>
Allconius
Člen | 313
+
0
-

Ahoj, tak jsem to nakonec zbaběle obešel, on ten dotaz dělal, že ze seznamu Základních škol vybíral jen ty kde je součástí i mateřská škola, tak to mám takto:

<?php

$result = $this->database->table($this->tabulka)
   ->where(''.$this->tabulka.'.smazano = ?', 0)
   ->where(''.$this->tabulka.'.kod = ?', 3)
   ->where(''.$this->tabulka.'.detas = ?', 0)
   ->where('LOWER('.$this->tabulka.'.nazev) LIKE ?', '%mateřská%');

?>