I'm using NetBeans since its version 7.0 and its my favorite IDE for PHP since than, but today I was using it for a project and its giving me problem in PDO code completion. There are two cases,
1) If I am instantiating the PDO object on the same page, than all of the code completion is correct.
2) But when I am keeping my PDO object in another file and requiring that file, than the code completion doesn't work.
EXAMPLES
1)
<?php
/**
* In this case the code completion works fine
*/
try {
$db = new PDO('mysql:host=localhost;dbname=tshop', 'root', 'mypass');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'SOME SQL QUERY';
$result = $db->query($sql);
} catch (Exception $ex) {
$error = $ex->getMessage();
}
2
<?php
/**
* But in this case it doesn't work
*/
try {
require_once '../../includes/database_connection.php';
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'SOME SQL QUERY';
$result = $db->query($sql);
} catch (Exception $ex) {
$error = $ex->getMessage();
}
Thank you Everyone in advance !