Static functions in PHP? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Static functions in PHP?

tvientitvienti Posts: 230Member
Hey,

I think I missed something in my PHP journey. Are there no static object methods in PHP (prior to 5, which I haven't even looked into yet)? I'm trying to wrap objects around my DB tables and giving each a select($id) method that is called on the class level and returns an instance... IE:

[code]$myAcct = Accounts->Select($id);[/code]

Is that not possible? Is there a workaround that's not more complicated than it's worth? I'm trying to avoid a DB wrapper class that's nothing but a series of variously named functions like selectAccount($id), selectUser($id), ...

Any help would be appreciated.

T

Comments

  • friendkeyfriendkey Posts: 3Member
    : Hey,
    :
    : I think I missed something in my PHP journey. Are there no static object methods in PHP (prior to 5, which I haven't even looked into yet)? I'm trying to wrap objects around my DB tables and giving each a select($id) method that is called on the class level and returns an instance... IE:
    :
    : [code]$myAcct = Accounts->Select($id);[/code]
    :
    : Is that not possible? Is there a workaround that's not more complicated than it's worth? I'm trying to avoid a DB wrapper class that's nothing but a series of variously named functions like selectAccount($id), selectUser($id), ...
    :
    : Any help would be appreciated.
    :
    : T
    :
    use [code]Accounts::Select($id)[/code] as Select is a static function.
  • tvientitvienti Posts: 230Member
    That's great! Such a simple thing makes such a big difference to my design. Thank you very much for your help.

    T

    : : Hey,
    : :
    : : I think I missed something in my PHP journey. Are there no static object methods in PHP (prior to 5, which I haven't even looked into yet)? I'm trying to wrap objects around my DB tables and giving each a select($id) method that is called on the class level and returns an instance... IE:
    : :
    : : [code]$myAcct = Accounts->Select($id);[/code]
    : :
    : : Is that not possible? Is there a workaround that's not more complicated than it's worth? I'm trying to avoid a DB wrapper class that's nothing but a series of variously named functions like selectAccount($id), selectUser($id), ...
    : :
    : : Any help would be appreciated.
    : :
    : : T
    : :
    : use [code]Accounts::Select($id)[/code] as Select is a static function.
    :

Sign In or Register to comment.