php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41356 Cannot retrieve global from a class in a soap server
Submitted: 2007-05-10 17:18 UTC Modified: 2007-05-10 17:32 UTC
From: simon at connexon dot com Assigned:
Status: Closed Package: SOAP related
PHP Version: 5.2.2 OS: Windows
Private report: No CVE-ID: None
 [2007-05-10 17:18 UTC] simon at connexon dot com
Description:
------------
For our application we use a $db which represents the database connection object.

In the class, instead of creating a new object every time, we do : global $db, which retrieves the database connection from outside the class.

That works good! 

However, when we call that class from a soap server, for some reason it does not get the $db variable (its blank)...

Reproduce code:
---------------
// Code
$db = new MySQL();


// class

class X extends A
{
        public function __construct($params)
	{
		global $db;
		$this->db = $db;
		$this->init($params);
	}

Expected result:
----------------
that the global $db; in the constructor contains the db connection

Actual result:
--------------
blank variable

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-10 17:32 UTC] simon at connexon dot com
using $GLOBALS instead of global seems to fix the problem
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC