1

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 already 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.

1
  • I'm confused. Doctrine is an ORM. You should be able to call some variety of "find" method on the model's class, and it should return either an object or a list from which you can instantiate objects. Can you show us the code so far that is failing to retrieve data? Commented Mar 17, 2011 at 20:12

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.