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

  • Home
  • SEARCH
  • 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 7086405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:32:44+00:00 2026-05-28T07:32:44+00:00

I’m developing a sort of Model in which I’d love to be able to

  • 0

I’m developing a sort of “Model” in which I’d love to be able to select few rows (or just one) by the constructor and then be able to treat them as an object so for example, selecting all the posts that has “admin” as author with a limit of 10 would be:

$posts = new Post(array(
    'where' => array('author' => 'admin'),
    'limit' => array(0 => 10),
    # optional: 'order' => array($by => 'desc/asc')
));

# get a field
$id = $posts->row[0]['id'];

# editing fields
$posts->row[1]['body'] = 'new body';
$posts->row[2]['body'] = 'new body for post # 3';
$posts->update();

# delete all the selected posts
$posts->delete();

... et cetera.

But what I don’t really like it the way it select the posts. It seems too mechanic and full of arrays in arrays that I don’t really like.
I also thought about “One object being one row” but this would take the require of 10 posts to perform 10 different queries. And that’s not efficient.

Question #1
Is there a similar pattern or similar script that could inspire me? Am I the first one that think that database rows could be seen as PHP object (with all the pros that come along with this concept).

Question #2
Could be there another way of selecting multiple rows? Could be a solution to force the developer to specify only the primary key of a table (such as the post id) as selector? (<= I don’t think this is a solution at all).

  • 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-28T07:32:44+00:00Added an answer on May 28, 2026 at 7:32 am

    Most ORMs (Object-Relational Mappers) try to give answers to your question in one or another way.

    I would suggest to have a look at Doctrine and at Propel to get ideas. Also, it would be good to see at other languages, such as Microsoft’s LINQ for .NET.

    Myself, I have recently published an ORM for PHP which is called Solid Oxygen. Have a look at the documentation, if you want. I believe that what I did is very close to what you try to develop.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm making a simple page using Google Maps API 3. My first. One marker

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.