Ask a Question related to PHP Development, Design and Development.
-
Yiannis Koutros #1
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
Yiannis Koutros Guest
-
What's better/faster, passing around and manipulating lists or one-dimensional arrays? Should a CFC argument be a list or a one-dimensional array?
What's better/faster, passing around and manipulating lists or one-dimensional arrays? Should a CFC argument be a list or a one-dimensional array? -
Passing an object as a property???
Is it possible to do sth like this ? Page's code part: Private xmlObj As New XmlDocument(......)... -
Passing an object
Hey again! I have a quick question about passing objects to other classes. What I am trying to do is create an object, and then pass that object... -
passing C++ object in VARIANT
I hope I unerstand the question correctly but normally its done like this. IDispatch* pDisp VariantInit(rVal); if (SUCCEEDED(hr =... -
passing an argument to a subroutine
Hello An argument passed to a subroutine returns wrong value. Code example: @x = (1..5); $x = @x; showValue ($x); # or showValue (\$x);



Reply With Quote

