NDB 2.1 Table\Selection and two joined tables?

Notice: This thread is very old.
Jelen
Member | 16
+
0
-

Hi,

I am using Nette Database in my project, but currently I have an issue with Table\Selection. Is there any option to make a delete() on where() with joining two tables? My database schema could be found here.
Point of interest (poi) have some attributes. M:N relations.
I am working with poi_has_attribute model using

$attributes = $database->table('poi_has_attribute')->where('poi_id', 1001)->where('attribute.type', 'CARD');

thats 1:N btw…

When I try delete those rows via $attributes->delete() I'll get:

Column not found: 1054 Unknown column 'attribute.type' in 'where clause'

When I try fetch() instead of delete() this rows, that is OK (that is wierd, count() and other function works fine too). I can delete them in foreach, but that will produce a lot of queries. Any idea?

Here is my query in sql:

DELETE pha
FROM poi_has_attribute pha
LEFT JOIN attribute a ON a.id = pha.attribute_id
WHERE pha.poi_id = 1001 AND pha.attribute_id NOT IN (200, 199) AND a.type = 'CARD'

and ndb

// Column not found: 1054 Unknown column 'attribute.type' in 'where clause'
$database->table('poi_has_attribute')->where('poi_id = ? AND attribute_id NOT IN ?', 1001, array(200, 199))->where("attribute.type = ?",'CARD')->delete();

Am I missing something?

// EDIT
When I use the count() function and knowingly make a mistake (poi_idd) it will produce a LEFT JOIN
but when delete() is used there is no LEFT JOIN…

Last edited by Jelen (2014-02-07 08:27)