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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:32:32+00:00 2026-05-14T02:32:32+00:00

I’m creating a small framework for my web projects in PHP so I don’t

  • 0

I’m creating a small framework for my web projects in PHP so I don’t have to do the basic work over and over again for every new website. It is not my goal to create a second CakePHP or Codeigniter and I’m also not planning to build my websites with any of the available frameworks as I prefer to use things I’ve created myself in general.

I have had no problems in designing and coding the framework when it comes to parts like the core structure, request handling, and so on, but I’m getting stuck with designing the database interface for my modules.

I’ve already thought about using the MVC pattern but found out that it would be a bit of an overkill for my rather small project(s).

So the exact problem I’m facing is how my frameworks modules (viewCustomers could be a module, for example) should interact with the database.

  • Is it (still) a good idea to mix in SQL directly into PHP code? (Would be “old way”: mysql_query( 'SELECT firstname, lastname(.....))?

  • How could I abstract a query like the following?

    SELECT firstname, lastname FROM customers WHERE id=X
    

Would MySQL “helper” functions like

$this->db->customers->getBy( 'id', $x );

be a good idea?

I’m not really sure because they tend to become useless when dealing with more complicated queries like the pretty much trivial one above.

  • Is the “Model” pattern from MVC my only real option to solve this?

  • What do you currently use to solve the problems shown above?

  • 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-14T02:32:33+00:00Added an answer on May 14, 2026 at 2:32 am

    If you need speed, then use raw queries (but you should really use PDO with prepared queries).

    If you want something more OOP, you can —as you suggest it— design this with helpers.

    Once, I’ve designed something similar which had the following concept:

    1. DB connection/handler classes (handling multi-connections to different databases and different servers such as MySQL, Oracle, etc.);
    2. A class per action (ie. SELECT, DELETE, etc.);
    3. Filter classes (eg. RangeFilter);

    The code looked something like this:

    $select = new Select('field1', 'field2', );
    $result = $select->from('myTable')
                     ->addFilter(SQLFilter::RangeFilter, 'field2')
                     ->match(array(1, 3, 5))
                     ->unmatch(array(15, 34))
                     ->fetchAll();
    

    It’s a simple example of how you can build it.

    You can go further and implements automated handling of table relations, field type check (using introspection on your tables), table and field alias support, etc.

    It might seem to be a long and hard work, but actually, it won’t take you that much time to make all these features (≈1 month).

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

Sidebar

Ask A Question

Stats

  • Questions 341k
  • Answers 341k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A dll is very much like an executable with a… May 14, 2026 at 4:58 am
  • Editorial Team
    Editorial Team added an answer You may want to check out the following: CSS Trick:… May 14, 2026 at 4:58 am
  • Editorial Team
    Editorial Team added an answer wxWidgets supports ribbon interfaces as well. May 14, 2026 at 4:58 am

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.