Nette 2.1 WHERE – OR a IN
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Juraj
- Člen | 10
Zdravím, vo verzii 2.0 mi tento kód fungoval správne:
$relationships = $this->rm->getRelationships($ofUser);
return $this->db->table('page_post')->where('author_id = ? OR author_id = ?', $ofUser, $relationships->select('user2_id, user1_id'))->order('datetime DESC');
Chyba: Column operator does not accept array argument
Ako sa to rieši v Nette 2.1? Ďakujem
- hrach
- Člen | 1844
V SQL nemuzes mit =
pro pole. Nove ndb to kontroluje,
repsektive uz to neprepisuje bezhlave jako driv, jenom umi to pridat. Tzn. mas
tyto moznosti:
return $this->db->table('page_post')->where('author_id ? OR author_id ?', ...);
return $this->db->table('page_post')->where('author_id IN ? OR author_id IN ?', ...);
S timze prvni je univerzalnejsi a operator prizpusobi podle argumentu, tj,
pokud predas null, tak to vytvori author_id IS NULL
. Druha moznost
vyzaduje pole, respektive \Traversable.