Dibi syntax in Nette Databsae
Notice: This thread is very old.
- Blujacker
- Member | 89
Hello,
so far I've been using dibi but lately, I am trying to switch over to Nette Database. I do like the new syntax (->table()->where…) however for some more complicated queries I still prefer to write the query myself. In dibi, I could use %and which would accept array (even nested arrays) and completed the query. I am struggling to achieve similar behavior with NDB. Is this even supported?
$where = array();
$where[] = array("((viewers_bouquets_active_from >= ?t and viewers_bouquets_active_from <= ?t
or (viewers_bouquets_active_to >= ?t and viewers_bouquets_active_to <= ?t)
or (viewers_bouquets_active_from <= now() and viewers_bouquets_active_to >= now()))", $from, $to, $from, $to);
$where["viewers_bouquets_viewers_id = ?"] = $this->viewers_id;
$query = $this->database->query("SELECT viewers_bouquets_active_from, viewers_bouquets_active_to, viewers_bouquets_subscribed, viewers_bouquets_cancelled, bouquets_name from viewers_bouquets inner join bouquets on viewers_bouquets_bouquets_id = bouquets_id where ?and order by viewers_bouquets_subscribed, bouquets_name, viewers_bouquets_active_from", $where);
Thank you,
Jakub
- Jan Tvrdík
- Nette guru | 2595
Generally – dibi syntax is much more powerful than Nette Database. Since
Nette 2.3 there is an ?and
placeholder which may help you, it is
however not as powerful as %and
in dibi.