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 1107493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:56:43+00:00 2026-05-17T01:56:43+00:00

I writing real estate web site with basic function for choosing and ordering realty.

  • 0

I writing real estate web site
with basic function for choosing and ordering realty.

It is small/simple project, but I want to write it in way,
so in future I, or other developers, can turn it into medium business app without rewriting it
from scratch.

So what kind of patterns could you advice me to use for dealing with database?

For now I have this:

class db_DBConnection
{
    // basic singleton pattern here...
}

// primary class to be extende by other table DAOs
abstract class db_Table
{
protected $table;
protected $order_by;

/**
 * Executes specified query with prepared statements
 * returns statement object, which can fetch data.
 * 
 * @param $sql - SQL query to execute
 * @param $params - bind values to markers through associative arrays
 */
protected function executeQuery($sql, $params = null)
{
    $dbh = db_DBConnection::getConnection();
    $stmt = $dbh->prepare($sql);
    // binds values to markers and executes query
    $stmt->execute($params);
    return $stmt;
}

/**
 * @param id - id of row to retrieve from database
 *
 * It sends SQL query and id to executeQuery
 * function returns associative array, representing
 * database row.
 */
public function find($id)
{
    $sql = 'SELECT * FROM ' . $this->table . ' WHERE id=:id LIMIT 1';
            // bind id
    $params = array( ':id' => $id );
    // execute and return associative array
    return $this->executeQuery($sql, $params)->fetch(PDO::FETCH_ASSOC);
}

public function findAll($quantity, $where)
{
// Returns array of
// associative arrays of table rows :)
// TODO: write this function
}

abstract protected function insert();

abstract protected function update();

abstract protected function delete();

    // ...
  • 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-17T01:56:43+00:00Added an answer on May 17, 2026 at 1:56 am

    The best way would be to use an ORM, like Doctrine. It might seem a little too much for smaller type project, but it pays off in a long run.

    It is better to use standard ways of doing things, instead of reinventing your own.

    Here is a list of ORMS from Wikipedia.

    Also you need to evaluate your project, creating project freestyle might not be a very good idea. Other developers will have to learn your code and understand how it works, etc… It is better to use well know frameworks like Zend Framework, Symfony or CakePHP. You can also look into expandable CMS systems like Joomla and Drupal.

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

Sidebar

Related Questions

I'm writing a simple real-estate listing app in Django. Each property needs to have
I'm writing a simple HTTP server and learning about TIME_WAIT. How do real web
I'm writing iOS application. There's a server related to some real estate. I've to
Part of a real estate application I'm writing will allow a user to subscribe
I'm interested in writing an x86 dissembler as an educational project. The only real
im writing a web crawler, using wxpython to display the real-time result. Assuming that
I'm writing a web application using node.js & express to provide a real-time aprs
I'm an experienced C/C++ Windows developer writing my first real iOS application. Since I
So I'm writing a Python package that will parse data from a real-time NOAAPORT
I've been working on a real mode OS, writing in assembly and compiling to

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.