By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

instance creation problem.

P: 11
Hi all,

I am using a static method to instantiate a member of my class (the member happens to be a class too). When I assign to that member, nothing seems to be sticking and all properties inside my member are null. But if I directly create my member without using a static method to create it, I have no problems.. heres an example... [using php 4.4.4 by the way so there are no descriptor keyowrds *static*]
[php]
class DataColumn
{

var $_datastore;

function DataColumn()
{
// this does not work - this is the problem i am talking about
$this->_datastore =& DataStorage::CreateStorage($this, $this->DataType);

// but, this will work
$this->_datastore =& new ObjectStorage();
}

}
[/php]
incase anyone is curious to what is happening in DataStorage::CreateStorage...
here it is.
[php]
class DataStorage
{

function CreateStorage($container,$dataType)
{
switch($dataType)
{
case "string":
return new StringStorage();
break;
case "int":
return new IntegerStorage();
break;
case "real":
return new RealStorage();
break;
case "object":
return new ObjectStorage();
break;
........... etc...
}
}
}
}[/php]
Any thoughts on this would be greatly appriciated.

Please enclose any code within the appropriate code tags. See Posting Guidelines! - moderator
Feb 23 '08 #1
Share this Question
Share on Google+
1 Reply


P: 11
anyone?? has anyone seen this?

I'm a .net developer and am just getting into php so any comments would help.
do I need to rephrase??

thanks -
odobo
Feb 24 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.