Why it not return?

Dear all i have 1 problem could you please help me


class SelectDatabase{
	function select($connect,$field,$table){
		$query = "SELECT ".$field." FROM ".$table;
		$stmt = $connect->prepare($query);
		$stmt->execute();
		return $stmt;
	}
	//public function __destruct(){}
}
$test = new SelectDatabase();
$test-> select($con,"*","test");
while($row = $test->fetch(PDO::FETCH_ASSOC)){
	echo $row['field1'].' '.$row['field2'].' '.$row['field3'].'<br />';
}

when i create function it work perfectly after i add it into the class it error now i have no idea with it
but the error happened:
Fatal error: Call to undefined method SelectDatabase::fetch() in C:\wamp\www\localtesting.com\ est\ est.php on line 84
please help me

You were close, your code needs to be updated (you are returning the value via the function call, so you need to catch the returned value and use it)

class SelectDatabase{
    function select($connect,$field,$table){
        $query = "SELECT ".$field." FROM ".$table;
        $stmt = $connect->prepare($query);
        $stmt->execute();
        return $stmt;
    }
    //public function __destruct(){}
}
$test = new SelectDatabase();
// you are returning the value via the function call, so you need to catch the returned value and use it
$statment = $test-> select($con,"*","test");
while($row = $statment->fetch(PDO::FETCH_ASSOC)){
    echo $row['field1'].' '.$row['field2'].' '.$row['field3'].'<br />';
}  

oh yes thank SitePoint Guru