PDO不在类中存储值

I'm a little confused at the moment because my DB class doesn't seem to be storing any results after a query (i.e. the 'results' property is still an empty array). The unsual thing is that when I transfer my logic outside a class definition it works perfectly.

My code with database credentials blanked out:

namespace DatabaseConnection;
use PDO;

class DB {

/*****STATES*****/
private $con;
private $results; 


/*****METHODS*****/
public function init(){

    $this->con = new PDO("***************************");
    $this->results = array();

    return $this;
}

public function getInfo(){
    if($this->con === null ) return "No Connection";
    else return "Connected"; 
}

public function getResults(){
    return $this->results;
}



public function retrieve(){
    $query = $this->con->prepare("select * from documents");
        $query->execute(); 


        while($row = $query->fetch(PDO::FETCH_ASSOC)){
        $this->results[] = $row;
        }



    return $this;
}

Try:

public function retrieve(){
    $query = $this->con->prepare("select * from documents");

    $query->execute();  //<---------

    while($row = $query->fetch(PDO::FETCH_ASSOC)){
       $this->results[] = $row;
    }

    return $this;
 }

OP is preparing a statement and then never executes it, and has no way of detecting this because of the utter lack of any error handling on the DB calls. – Marc B