Undefined variable

I use PDO for the database connection. All the PDO stuff has been initialized in a file application_top.php.

if(!isset($db)) {
  $db = new Morrow\Db(array(
    'driver'   => 'mysql',
    'host'     => DB_SERVER,
    'db'       => DB_DATABASE,
    'user'     => DB_SERVER_USERNAME,
    'pass'     => DB_SERVER_PASSWORD,
    'encoding' => '"utf8"',
  ));
}

This works fine. But PHPStorm gives me a warning

Undefined variable 'db'

The code looks like

require_once 'includes/application_top.php';
...
$pass = $db->result_one("
  SELECT customers_password
  FROM   " . TABLE_CUSTOMERS . "
  WHERE  customers_id = " . (int)$_SESSION['customer_id']
);

But why is $db undefined?

Greetz

Ron

Please sign in to leave a comment.