I am working on a custom module for a project that uses one sql query. Everything went great through testing until I tried my module with a non-superuser account.
When viewing the error there appears to be some sort of conflict with nodeaccess -- this has been confirmed by disabling nodeaccess module and then my module works correctly with the non-superuser account.
I'm not sure if I'm doing something wrong in my code -- any ideas?
error message:
user warning: Unknown column 'n.nid' in 'on clause' query: SELECT * FROM node n, content_type_stomp dt INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 2 AND na.realm = 'nodeaccess_rid') OR (na.gid = 4 AND na.realm = 'nodeaccess_rid') OR (na.gid = 6 AND na.realm = 'nodeaccess_uid') OR (na.gid = 6 AND na.realm = 'nodeaccess_author'))) AND ( n.type = 'stomp' AND n.status = 1 AND dt.nid = n.nid AND dt.field_datetimestamp_value >= 1224822473 )ORDER BY dt.field_datetimestamp_value ASC ;
My snippet of sql query:
// query db to find next STOMP event
$type = 'stomp';
$status = 1;
$stomp_sql = "
SELECT *
FROM {node} n, {content_type_stomp} dt
WHERE n.type = '%s'
AND n.status = %d
AND dt.nid = n.nid
AND dt.field_datetimestamp_value >= %d
ORDER BY dt.field_datetimestamp_value ASC
;";
$result = db_query(db_rewrite_sql($stomp_sql), $type, $status, $timestamp);
//extract the output
$data = db_fetch_object($result);
$node = node_load($data->nid);
It appears that nodeaccess is altering my sql query in someway(?) -- this is beyond me. Any help is greatly appreciated!
Comments
Comment #1
3cwebdev commentedOkay, I removed the db_rewrite_sql from my query and all is working okay now.
Comment #2
Anonymous (not verified) commented