Can I use SQL array as in Dibi?

8 days ago

Robin Martinez
Member | 43
+
0
-

Hi,

I love Dibi and use it a lot. I heavily used sql array to feed Dibi such as:

$q = []
array_push('SELECT * FROM %n', $table);
array_push('WHERE id > %d', $id);

$res = dibi::fetchAll($q);

I guess this is not possible in Nette Database? The only ‘similar’ method I found is:

$q = $args = [];
$q[] = "SELECT * FROM ?";
$args[] = $table;

$q[] = "WHERE id > ?";
$args[] = $id;

$res = $this->db->fetchAll(implode(' ', $q), ...$args);

Or is there any ‘cleaner’ method? Thanks!

8 days ago

CZechBoY
Member | 3540
+
0
-

Why not to use dibi if you know it?

8 days ago

Robin Martinez
Member | 43
+
0
-

I just started a new job, where Nette is used. So I'd like to know if I can use old habits :)

8 days ago

CZechBoY
Member | 3540
+
0
-

I'm not sure if this work, but try it :D
->where($q, $args)