Passing database resource to object (OO)

From: Date: Mon, 11 Aug 2003 19:04:38 +0000
Subject: Passing database resource to object (OO)
Groups: php.general 
Request: Send a blank email to php-general+get-159175@lists.php.net to get a copy of this message
Wan I insatiate an object I want to pass a database resource that can be used throughout the object. The below code should indicate what I want but I get the error "mysql_query(): supplied argument is not a valid MySQL-Link resource". I guess this is because "$this->$db = $db" is wrong. Ben class Contacts{
        var $SESSION = array();
        var $db;
        function Contacts( $SESSION, $db ) {
                $SESSION = array();
                $this->$db = $db;
                echo $this->db;
        }
****************************************************************
* Ben Edwards           Tel +44 (0)1179 553 551  ICQ 42000477  *
* Homepage - nothing of interest here http://gurtlush.org.uk *
* Webhosting for the masses         http://www.serverone.co.uk *
* Critical Site Builder    http://www.criticaldistribution.com *
* online collaborative web authoring content management system * * Get alt news/views films online http://www.cultureshop.org *
* i-Contact Progressive Video      http://www.videonetwork.org *
* Fun corporate graphics             http://www.subvertise.org *
* Bristol Indymedia               http://bristol.indymedia.org *
* Bristol's radical news             http://www.bristle.org.uk *
****************************************************************

« previous php.general (#159175) next »