I have a little problem with save realtion ManyToOne
it look like that:
Document - Language
Document has one Language
Language has many Docuemnt
I have try something like that:
- Code: Select all
lang = new Language();
lang->name = "English";
document = new Document();
document->language = lang;
document.save(); // <- is the same like qx::dao::save(document)
But it dose not work, document is saved with very strange language_id (random). But language is saved correct.
I think this is because language is saved after saved document
I have tried to save language before document and it works.
Like that:
- Code: Select all
lang = new Language();
lang->name = "English";
lang.save(); // is the same like qx::dao::save(lang);
document = new Document();
document->language = lang;
document.save(); // <- is the same like qx::dao::save_with_all_relation(document)
So question: Do I need save lang before document? Or it should work using only save_with_all_relation on document?
I will be very greatfull for any example that work. Those example on qxOrm website work but all object are saved before relation so I am not sure if this is possible.
Thanks a lot for any clue.