instance creation problem.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • odobo
    New Member
    • Feb 2008
    • 11

    instance creation problem.

    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::Cr eateStorage($th is, $this->DataType);

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

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

    function CreateStorage($ container,$data Type)
    {
    switch($dataTyp e)
    {
    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
    Last edited by ronverdonk; Feb 24 '08, 12:57 PM. Reason: code within tags
  • odobo
    New Member
    • Feb 2008
    • 11

    #2
    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
    Last edited by ronverdonk; Feb 24 '08, 12:56 PM. Reason: thread cleanup

    Comment

    Working...