Why isn't my foreach loop displaying my mysql data?
<p>I am trying to extend the function of <a href="https://www.youtube.com/playlist?list=PLfdtiltiRHWF5Rhuk7k4UAU1_yLAZzhWc&amp;spfreload=5" rel="nofollow noreferrer">this tutorial on youtube</a>, and I have run into some issues. Here is the particular chunk of code I am currently struggling with: </p>

<pre><code>public function listProjects() {
    $projects = DB::getInstance()-&gt;get('projects', array('projectStatus', '=', 'active'));
    if($projects-&gt;count()) {
        echo 'This query senses rows, but returns data it does not';
        foreach($projects as $project) {
            echo $project-&gt;projectName;
        }
    }
}
</code></pre>

<p>This is a method of my "Project" class, and it uses methods from the DB class, with relevant code here:</p>

<pre><code>private function __construct() {
    try {
        $this-&gt;_pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/db'), Config::get('mysql/username'),  Config::get('mysql/password')); 
    } catch(PDOException $e){
        die($e-&gt;getMessage());
    }
}


public static function getInstance() {
    if(!isset(self::$_instance)){
        self::$_instance = new DB();
    }
    return self::$_instance;
}


public function query($sql, $params = array()){
    $this-&gt;_error = false;
    if($this-&gt;_query = $this-&gt;_pdo-&gt;prepare($sql)) {
        $x = 1;
        if(count($params)) {
            foreach($params as $param) {
                $this-&gt;_query-&gt;bindValue($x, $param);
                $x++;
            }
        }
        if($this-&gt;_query-&gt;execute()) {
            $this-&gt;_results = $this-&gt;_query-&gt;fetchAll(PDO::FETCH_OBJ);
            $this-&gt;_count = $this-&gt;_query-&gt;rowCount();
        } else {
            $this-&gt;_error = true;
        }
    }
    return $this; 
}


public function action($action, $table, $where = array()) {
    if(count($where) === 3) {
        $operators = array('=', '&gt;', '&lt;', '&gt;=', '&lt;=');

        $field = $where[0];
        $operator = $where[1];
        $value = $where[2];

        if(in_array($operator, $operators)) {
            $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?";
            if(!$this-&gt;query($sql, array($value))-&gt;error()) {
                return $this;
            }
        }

    } return $this;

}


public function get($table, $where) {
    return $this-&gt;action('SELECT *', $table, $where);

}
</code></pre>

<p>So in my index.php, I write this code:</p>

<pre><code>$projectList = new Project;
$projectList-&gt;listProjects();
</code></pre>

<p>To try and retrieve all of my "projects" stored in the database. I put the "This query senses rows, but returns data it does not" echo in order to determine if rows were being counted, which they are, because that statement is echoed, but my foreach statement is not working correctly. The field in the projects table that I am trying to access is projectName. I would eventually like to display all relevant project info, but I'm sure I could figure that out once I get it to display anything from the database.</p>