Passing an object as an argument

This is a discussion on Passing an object as an argument within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I hava a class that i use to connect with my db. After I instantiate the class and I am ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-20-2004
Yiannis Koutros
 
Posts: n/a
Default Passing an object as an argument

I hava a class that i use to connect with my db. After I instantiate the
class and I am connected with the database i save the connection link to a
property, which is a resource type.
I want to pass the whole object that i am creating and use the connection
inside another class. But when i do sth like the following there is a fatal
error that the mysql link is not a valid resource identifier.


class connection{
var $link;

function connect(){
$this->link = blalba
}
}

class thirdClass(){
var $connectionObject;

function thirdClass($connectionObject){
$this->connectionObject = $connectionObject;
}

function test(){
$this->connectionObject->executeQuery($query);
}

$myConnection = new Connection();
$myConnection->connect();

$myObject = new $thirdClass($myConnection);


I tried to serialize the object but that is meaningless as when you
serialize an object it is not saved the resource type.



Yiannis


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:42 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0