We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Some ODM Questions

HI all I would like to use an ODM (surely mongoDB) database and would like some things to be clarified.

Firstly, Is the doc page is up to date to develop ODM collections with php7 (with the mongo class deletion) ? I saw somewhere I'll need to include the incubator, is it still true, or the new class from incubator are now in phalcon ?

I have some questions about the "Model" too. I worked for a while with zend framework 2 and Doctrine ODM.

Is there anything equivalent to the doctrine annotation ? (to specify the field type, the filed name if needed, the relationship, if the field is an EmbedDocument, etc.)

How are managed relationships between collections ? (didn't see anything about this in the ODM doc page)

How are managed EmbedCollection ?

For the default "_id" field, do I have to name a field $_id in my collection PHP class to access it ?

I think I saw that the id field is included in MongoCollection Class but I would like a confirmation.

Thanks in advance for the answer.



8.2k
edited Nov '17

After some research and starting to change Model to Collection, I saw there is no relationships, no hasChanged function or things like that (that I need).

the ODM classes lacks on lot of features, that's sad. I'll wait some big update to that to change from SQL to NoSQL



79.0k
Accepted
answer

Well, yes, ODM needs better support in Phalcon. But you can always develop your own implementation, following Phalcon's interfaces and perhaps even submit a PR with that code.



8.2k

I'll think about that but actually, I haven't enought time to develop my personnal app, so I don't think I'll lose more time on this for now. As I said I'll keep up with SQL and maybe will work on ODM later.

My goal for my app is to share it with the most possible features, so add support for SQL and NoSQL. but NoSQL will wait a bit.

I'll fork the incubator to start thinking a bit about possible PR in the future though.