php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55043 not throwing error on wrong syntax
Submitted: 2011-06-12 17:16 UTC Modified: 2011-06-12 17:59 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: khurramijazm at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.6 OS: windows7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: khurramijazm at gmail dot com
New email:
PHP Version: OS:

 

 [2011-06-12 17:16 UTC] khurramijazm at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/internals2.objects
---
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);
    }

}

Expected result:
----------------
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();** ERROR SHOULD BE REPORTED HERE
WHEN USING self:$instance , it SHOULD BE THE SCOPE RESOLUTION OPERATOR WITH DOUBLE COLON ::...Sorry if it is not a bug but some thing i don't have knowledge of..
        }
        return self::$instance;
    }

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

}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-12 17:36 UTC] khurramijazm at gmail dot com
After researching i narrow down the problem to that in PHP you can declare a reserved keyword as a goto label: because in the above sent bug report php must have thought of it as an goto label i.e. 

self: $instance = ....

i hope it helps
 [2011-06-12 17:59 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-06-12 17:59 UTC] felipe@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC