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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:33:32+00:00 2026-05-23T03:33:32+00:00

i created a small PDO class and spent hours in debugging it and could

  • 0

i created a small PDO class and spent hours in debugging it and could not find a small typo which was causing every thing to fail. To demonstrate below is the buggy code.

    class MyPDO  extends PDO
{
    private static $instance = null;
    function  __construct(){
        try{
        parent::__construct("mysql:host=localhost;port=3306;dbname=blog", "root", "");
        parent::setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
        }catch(PDOException $e){
            echo 'Exception in constructor'.print_r($e->trace(),true);
        }

    }

   static public function getDB(){
        if(self::$instance == null){
            self:$instance = new MyPDO();
        }
        return self::$instance;
    }

    function selectAll($sql){
            $stmt = self::$instance->prepare($sql);
            $stmt->execute(array(":cat_id"=>1));
            return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

}

What i want to confirm that if any one has already seen it or is it a bug or it could be used for some thing else i have no knowledge of.

There is a problem with the following line i wrote.

self:$instance = new MyPDO();

it should be the scope resolution operator with double colon i.e.

self::$instance = new MyPDO();

To my surprise no warning or error is generated with a single colon .. If any one knows about this please share.

  • 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-23T03:33:33+00:00Added an answer on May 23, 2026 at 3:33 am

    In this instance you are defining a jump label (think goto).

    self:  $instance = new MyPDO();
    

    And $instance will just become a local variable.

    So yes, it is sort of a bug that you can use a reserved word for a label.

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

Sidebar

Related Questions

I have created a small application which opens,reads and creates Excel files. The app
I want to globalize my application. I have created a small form which asks
I have created small test web application which makes use of LINQ to SQL.
I created a small example to demonstrate the issue I'm having. First my class:
I created a small program in PHP which sends newsletter. It's fine when I
I created a small shell script which logs all of it's input to a
I have created a small program which logs text data to a file on
I've created a small class that loads dictionary items from a plist file. The
Morning! I've created a small NDK project which allows dynamic serialisation of objects between
A researcher has created a small simulation in MATLAB and we want to make

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.