Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:26:14+00:00 2026-05-23T14:26:14+00:00

I’ve been working on a CMS project (using Zend Framework) to brush up my

  • 0

I’ve been working on a CMS project (using Zend Framework) to brush up my skills and have hit a bit of a wall. I decided early on to adopt the data mapper pattern (http://martinfowler.com/eaaCatalog/dataMapper.html) when handling database interaction due to the nice separation in logic between the business model and underlying storage.

An example of why I want this separation is that domain object properties won’t necessarily have the same name as the underlying database column (i.e. there’s a naming scheme for primary keys and foreign keys helping with automated inserts and lazy loading).

I adapted tutorials following & based on survivethedeepend.com however every sample/example/tutorial implementation I’ve seen completely ignores how to handle retrieval when the objects aren’t being retrieved by ID. I’ve been checking tutorials across multiple languages to try and get the clue but they all only seem to handle insert, update by ID, delete by ID & select by ID!

So I’ve got a few questions, the first of which is how would you go about retrieving on non-primary key fields? Is the usual way to create a specific method per required retrieval i.e. ‘$entity->findByName(‘Bob’);’. That seems terribly rigid and unwieldy in the long run.

And how about retrieving for properties on the object which have a different name in the database? I’ve been thinking about having a generic select method which takes in 3 arguments (the object property name, the modifier to embed in the where clause e.g. ‘=’ or ‘>’ and the value to match). But I don’t think this sits with the idea of the fairly rigid structure of the data mapper pattern.

Can anyone please advise on how would be best to proceed? Has anyone come across this & if so, how did you work it?

I’m aware projects like Doctrine exist to handle this however I’d rather develop an ‘in-house’ solution at this time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:26:14+00:00Added an answer on May 23, 2026 at 2:26 pm

    Having a couple of findByXXX() methods is no more rigid than having getters and setters on your models for your properties.

    As for properties that have different names in the database: name your findBy methods after the object properties, not after the database columns. After all, if your object property is called name and you have a getName() and setName() method, it is only logical that the selector method is called getByName(), even though the actual database column is called something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.