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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:12:48+00:00 2026-05-18T12:12:48+00:00

I am building a 3rd-party library that requires a database access. To be more

  • 0

I am building a 3rd-party library that requires a database access. To be more specific, it’s an access control library. Currently the biggest problem I am facing is that how do I make it compatible with most frameworks and CMS’s?

I could issue queries using a database instance that the developer specifies. This has three problems:

  • I need an access to a database instance.
  • The library needs to be able to deal with different database instances (PDO, MySQLi, mysql-resource, postgresql-resource, etc.)
  • There would be no caching, because the queries do not go through the application (assuming the app uses some).

Or I could just have methods that return the SQL, but is that any better?

  • 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-18T12:12:49+00:00Added an answer on May 18, 2026 at 12:12 pm

    The Adapter Design Pattern springs to mind

    An “off the shelf” component offers compelling functionality that you would like to reuse, but its “view of the world” is not compatible with the philosophy and architecture of the system currently being developed.

    For your concrete problem this means you create a class for your framework that exposes an API with all the method required by your other classes. This is the only interface you will interact it. Then you create adapters for each database you want to support. So your adapter will become the meditator between your framework and the DAL.

    Example:

    interface DB_Interface
    {
        public function somethingYourFrameworkUses();
    }
    
    class YourDB implements DB_Interface
    {
        public function setAdapter(DB_Interface $adapter)
        {
            $this->adapter = $adapter;
        }
        public function somethingYourFrameworkUses()
        {
            $this->adapter->somethingYourFrameworkUses();
        }
    }
    

    The above is your main class. You will only interact with this class from your remaining framework’s code. The functionality required to interact with a specific database is contained within a concrete adapter then. You instantiate and inject an adapter at runtime.

    class PDO_Adapter implements DBInterface
    {
        public function somethingYourFrameworkUses()
        {
            // code to make this function work with PDO
        }
    }
    
    class MySQLi_Adapter implements DBInterface
    {
        public function somethingYourFrameworkUses()
        {
            // code to make this function work with MySQLiAdapter
        }
    }
    

    Add additional adapters as you see fit.

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

Sidebar

Related Questions

I want to create a shared library that uses functions from a 3rd-party static
When building static libraries with VS2005 I keep getting linker warnings that VC80.pdb cant
In building an ASP.NET 3.5 WAP, I'm always frustrated by the feeling that no
I'm building a website that will require user registration and logon. I would like
I am building an application as a library, but to make sure I can
Building an app with the Facebook JavaScript API that will embedded into a page
Building on How Do You Express Binary Literals in Python , I was thinking
Building a client-side swing application what should be notified on a bus (application-wide message
Building the same project (without any changes) produces binary different exe-files: some small regions
Building on what has been written in SO question Best Singleton Implementation In Java

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.