How to get the generated sql query with Nette\Database\Explorer

Member | 13

Background: I know the domain logic of the application and therefore the raw queries needed.
$search_arr = ['nllee', 'sseia']
and the result should look like this

FROM artikel
    (`artnr` = 'nllee') OR
    (`benennung` LIKE '%nllee%') OR
    (`herstartnr` LIKE '%nllee%') OR
    (`longwg` LIKE '%nllee%') OR
    (`longwg2` LIKE 'nllee%') OR
    (`ean` LIKE 'nllee%')
) AND (
    (`artnr` = 'sseia') OR
    (`benennung` LIKE '%sseia%') OR
    (`herstartnr` LIKE '%sseia%') OR
    (`longwg` LIKE '%sseia%') OR
    (`longwg2` LIKE 'sseia%') OR
    (`ean` LIKE 'sseia%')

How do I get this done with Nette\Database\Explorer ?
Is there the possibility to get the generated queries????

I do not want to use raw sql, because we might go from mysql to postgres in the future and I would like to keep the queries hidden in the orm. The migration is a endless threat by the management.

I do already know, how to get there with dibi, but I would like to learn, how to get there with Nette\Database\Explorer

With dibi it is like this:

        $qarr  = [];
        foreach ($search_arr as $search_str) {
            // $search_str = addslashes($search_str);
            $qarr[] = [
                '%or', [
                    'artnr' => $search_str,
                    'benennung%~like~' => $search_str,
                    'herstartnr%~like~' => $search_str,
                    'longwg%~like~' => $search_str,
                    'longwg2%like~' => $search_str,
                    'ean%like~' => $search_str
        $_artdaten = $this->database->query('SELECT artnr FROM artikel WHERE %and ', $qarr)->fetchAssoc('artnr');

Thanks a lot

Kamil Valenta
Member | 757
$selection = $database->table('artikel');

foreach ($search_arr as $search_str) {
    $selection->where('artnr = ? OR benennung LIKE ? OR herstartnr LIKE ?', $search_str, $search_str, $search_str);
Member | 13

Thanks, that helped.

and to answer my own question how to get the generated query:


retrieves the query

Thanks a lot like