I need to reuse this function so that it uses fetchAll but also use num_rows, the problem is that if I do return fetchAll or num_rows it works, but in that case I would have to create two functions just for one to use fetch and another rows, because if I command to return the execute and I try to use the fetch the nuws in this way of the error: getList () -> fetchAll (); I want to use it like this:
public function getList($table = "produto",$orderTable = "id",$order = "ASC",$limited = 1){
$this->list = parent::Conecta()->prepare("SELECT * FROM $table ORDER BY $orderTable $order LIMIT :limited");
$this->list->bindValue(":limited",$limited,PDO::PARAM_INT);
return $this->list->execute();
getList () -> num_rows or getList () -> fetchAll () using only a single function, but gives error, only works if I create a function for each example:
public function getList($table = "produto",$orderTable = "id",$order = "ASC",$limited = 1){
$this->list = parent::Conecta()->prepare("SELECT * FROM $table ORDER BY $orderTable $order LIMIT :limited");
$this->list->bindValue(":limited",$limited,PDO::PARAM_INT);
$this->list->execute();
return $this->list->fetchAll();