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 was created one small business application..Here I got the data from server and
I have created a small PSD Mockup of a about page for my website.
Recently I noticed a small bug in my code which uses Reactive Extensions. I
I want to have a small QFormLayout that grows to fill its parent widget.
Have a small doubt with static method. Documentation says that Static method can't access
I have created the following registry key (copied through regedit): HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\test I would like
Consider this small snippet of JavaScript: for(var i in map.maps) { buttons.push($(<button>).html(i).click(function() { alert(i);
I created an AVD. resolution: 540 x 960 hw.lcd.density: 275 Before starting the AVD
I have written a small unit test for my django view .My project structure
tl;dr version: Is there a way to force a strict mode for JAX-WS that

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.