Zend model function data access using Doctrine
I am working in Zend framework using Doctrine. If I want to write business logic in model function, how can I retrieve table record from within model function using Doctrine.
I have a blog and tag module. While adding a blog, I can give tags in comma separated fashion. I can save the blog record from controller. When saving the tags, I need to check if those tags alre开发者_高级运维ady exists in table. For that, I can write a function in model and call it from the controller. This function will check if tag is present. If it is already there, it will return the tag id or it will save the tag and return the new id.
Now my question is how can I retrieve tags table record from model function. Please help me.
The Blog model's doctrine base class should be configured to have an association with the tag table. Then you should be able to refer to the tag using objects and doctrine will handle the database queries.
http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html
精彩评论