Triggering event silently.
This is an open discussion with 3 replies, filed under Troubleshooting.
Search
Im referencing to $entrydata[38]['relationid'] and i don't know what is 38. Is this id going to change if i, for example, add some fields into the section?
The only way the ID for that field would change is if you deleted the field and added it back again into your section.
How can i force EntryManager to return only the field i'm looking for? I must use 'where' clause but i don't know how.
Not sure, but if the only data you need to retrieve is the entry ID then you should be fine just doing a custom SQL statement for that table and using a where clause.
SELECT entry_id FROM sym_entries_data_38 WHERE relation_id = '{$relation}'
Actually, initial function was incomplete - it checks only for matching discussion, when it has to check both member and discussion.
However @Lewis pointed me to the right way (thanks!), all i need was simple SQL query.
There is result:
// returns entry id or false protected function isEntryExists($discussionId, $memberId){ $sql = " SELECT sym_entries_data_38.entry_id FROM sym_entries_data_38, sym_entries_data_39 WHERE sym_entries_data_38.relation_id = '{$discussionId}' AND sym_entries_data_39.relation_id = '{$memberId}' AND sym_entries_data_38.entry_id = sym_entries_data_39.entry_id "; $rows = Symphony::Database()->fetch($sql); if (!empty($rows)) { return $rows[0]['entry_id']; } else { return false; } }
Welcome, glad you worked it out.
Create an account or sign in to comment.
Hello.
The scenario : i need to track pages visited by authorized users (kind of 'mark as read' functionality for forum threads).
It's easy to do with ajax, triggering event after page loads, but it adds possibility of mistake, for example if ajax request hangs or js error occurs somewhere on the page, etc.
After reading this fine explanation of Events from brendo i tried to write custom event. Suddenly, it worked. Here is the source code :
http://pastie.org/2739462
However, i have couple of questions about EntryManager. This is my function to get id of entry, if it exists:
Structure of my section is :
Thanks in advance!!