Bug #55043 [NEW]: not throwing error on wrong syntax
| From: | khurramijazm at gmail dot com | Date: | Sun, 12 Jun 2011 15:16:37 +0000 |
| Subject: | Bug #55043 [NEW]: not throwing error on wrong syntax | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-161344@lists.php.net to get a copy of this message | ||
From:
Operating system: windows7
PHP version: 5.3.6
Package: Class/Object related
Bug Type: Bug
Bug description:not throwing error on wrong syntax
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);
}
}
--
Edit bug report at http://bugs.php.net/bug.php?id=55043&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=55043&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=55043&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=55043&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=55043&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=55043&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=55043&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=55043&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=55043&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=55043&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=55043&r=support
Expected behavior: http://bugs.php.net/fix.php?id=55043&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=55043&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=55043&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=55043&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=55043&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=55043&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=55043&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=55043&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=55043&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=55043&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=55043&r=mysqlcfg