Accessing method (beginner)

-1

I started my studies recently and a question arose about accessing information for a method. I have an X.php file that has the following structure:

public function selectDB($sql,$params=null,$class=null){
    $query=$this->connect()->prepare($sql);
    $query->execute($params);

    $total_q = $query->rowCount();


    if(isset($class)){
        $rs = $query->fetchAll(PDO::FETCH_CLASS,$class) or die(print_r($query->errorInfo(), true));
    }else{
        $rs = $query->fetchAll(PDO::FETCH_OBJ) or die(print_r($query->errorInfo(), true));
    }
    self::__destruct();
    return $rs;
} 

And I have a Y.php page that makes use of this function. How do I make the Y.php page display the value of the $total_q variable?

Could someone please give me a light?

    
asked by anonymous 22.03.2018 / 15:56

1 answer

-1

You can call the X.php file in Y.php the way you will use depends on how you want to use the X.php file You can use: include 'X.php'; require 'X.php'; require_once 'X.php';

The choice of method to use is yours but basically it is referring to the handling of errors, in the include it only displays a warning and continues execution of the script, it does not require it to run if it gives some error in the code

    
22.03.2018 / 16:06