I have a many to many relationship entities - entitieskeywords (entitiesid, keywords_id) - keywords. Searching works fine and as described. Now I want to save new entities. If the keywords are not stored in the database and I call entity->save() everything works great. But if just one of the keywords already exists, the whole query fails. So I want to override the save()-function in the model and after reading documentation and searching in the forum (some users got the same behaviour) I'm not quite clear how to do it properly.
My idea for creation a new entity: First I get all keyword as comma-seperated string; second I explode the string and search if the keyword exists, if not I save it; third I save entity's main data; fourth I save entity-keywords to the table (entities_keywords).
Questions are now: - How do I only save entity's main data? ... probably with parent::save($data)? And should I call it in Entities->save()? - If I get the keywords in $data['keywords'] where is the best place to check if they already exists? And how to prevent them from being stored by phalcon's built-in save-function?
It's very sad, that the manytomany-relation works fine for reading but makes saving much complicated :/
Thanks a lot.