In my DB layer class I have a method that takes a select sql query as param:
public function select($sqlQuery) {
$stmt = $this->pdo->prepare($sqlQuery);
$stmt->execute();
$ret = $stmt->fetch(PDO::FETCH_ASSOC);
return $ret;
}
I want to be able to return the fetched data to my model, and then loop through it in my view class, without using any PDO in the view.
How should this be done the right way?
I want to be able to reach the table rows as $row[‘testCol’] etc.
Call
fetchAll()instead offetch(), which will return a full multidimensional array.