1
I need to reuse this function so that it uses fetchAll but also use num_rows, the problem is that if I return fetchAll or num_rows it works, but in that case I would have to create two functions just to use fetch and the other Rows, because if I return the execute and try to use fetch the nuws this way from the error: getList()->fetchAll(); I want to wear 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();
what kind of mistake?
– Felipe Duarte
It says that the getList method is undefined, see: Fatal error: Uncaught Error: Call to Undefined Function getList() in
– Otavio Fagundes