How this works ????

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How this works ????

    Hello CT,

    i have a question.....


    i have write a simple class with 2 function which is here

    PHP Code:
    CLASS db{

        public function 
    select(){
            
    $arg func_get_args();
            if(empty(
    $arg)):
                
    $selectClust "*";
            else:
                
    $selectClust implode(',',$arg);
            endif;
            
        return 
    "SELECT ".$selectClust;
        }
        
        public function 
    from(nsqlQuery $e){
            
    $arg func_get_args();
            return 
    "FROM ".rtrim(implode(' ',$arg));
        }


    and wanna use these function as

    PHP Code:
    <?php

    db
    ::select()->from('table');

    ?>
    but it is showing me error...

    what should i do in my class/functions so i can use it as i want...

    plz help me... thanks is advance...
    Sandeep DiL (INDIAN)




    #2
    try using the class like this:
    PHP Code:
    CLASS db{

        public static function 
    select(){
            
    $arg func_get_args();
            if(empty(
    $arg)):
                
    $selectClust "*";
            else:
                
    $selectClust implode(',',$arg);
            endif;
            
        return 
    "SELECT ".$selectClust;
        }
        
        public static function 
    from(nsqlQuery $e){
            
    $arg func_get_args();
            return 
    "FROM ".rtrim(implode(' ',$arg));
        }


    then this:
    PHP Code:
    <?php

    db
    ::select()->from('table');

    ?>
    should work correctly.

    to use a class like db::somthing
    you need to either...
    1) make the class static (like i have here)
    2) or you need to make a constructor thats calls a function inside the class, that will make the class a single call each time its called.
    <?php
    include ('Ghost');
    if ($Post == true) {
    echo '

    sigpic
    alt='coding-talk.com!!' />';
    echo 'Sharing Is Caring!';
    } else {
    echo '

    alt='the username GHOST has been comprimised!' />';
    echo 'OMG SOMEBODY HELP ME!!';
    }
    ?>

    Comment

    Working...
    X