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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:26:38+00:00 2026-06-14T04:26:38+00:00

How can one access PDO’s execute() method from inside a db class? Below is

  • 0

How can one access PDO’s execute() method from inside a db class? Below is a snippet of my class and method:

class db extends PDO {
        public $memcache;

        function execute($params='') {
            try {$foo=parent::execute($params);}
            catch (PDOException $e) {echo $e->getMessage();}
            return $foo;
        }

        function __construct($db='server_en',$host='localhost',$uz='root',$pw='') {
            try {
                parent::__construct("mysql:dbname=$db;host=$host",$uz,$pw);
                parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
            }
            catch (PDOException $e) {echo $e->getMessage();}
            $this->memcache=new Memcache;
            $this->memcache->connect('127.0.0.1', 11211) or die('Could not connect to Memcache server');
        }
    }

I have tried executing the following code:

var_dump($db->execute('INSERT INTO `foo`(`bar`) VALUES (0)'));

And got the following error: Fatal error: Call to undefined method PDO::execute() in ....

Could anyone please supply a simple example of how this can be fixed? I am fairly inexperienced with both PDO and classes, so the simpler the answer the better.

P.S. The reason for me replicating some of PDO’s methods is easier migration to a new db handler when PDO becomes outdated. This is not premature optimization; this is making life easier from the start.

  • 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-06-14T04:26:40+00:00Added an answer on June 14, 2026 at 4:26 am

    You can only call ::execute() on a PDOStatement, not PDO itself.

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

Sidebar

Related Questions

How can I access a variable in one public class from another public class
How can we access variable from one Xaml file in to another xaml file
How can one access LIM from R ?
Each request in my web app can get one data access object instance (of
When using the Scripting Bridge to access the Mail app one can easily retrieve
According to man 5 proc , one can use the /proc filesystem to access
I'd like to have access to one my model field verbose_name. I can get
In Jinja2, how can one access assigned variables (i.e. {% set X=Y %} )
Which one can be the better one data access component for desktop application and
How can one access model's validation message through ModelState variable at the controller?

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.