0
How do I rework this function to make a select
in more than one table, dynamically ?
public function Lista(){
$results = array();
$stmt = $this->conn->prepare("SELECT * FROM 'tabela'");
$stmt->execute();
if($stmt) {
while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$not = new Not();
$not->setid($row->ID);
$not->setimg1($row->Img1);
$not->setimg2($row->Img2);
$not->setimg3($row->Img3);
$results[] = $not;
}
}
return $results;
}
Because I need several select’s in several tables I could not find a simple way, except to make a function for each select. The same is repeated for update
and insert
. Any hint ?
Have you considered moving to the function the table name as argument? no
prepare
you do something like that:"SELECT * FROM '$nomeTabela'"
.– stderr
Search for Inner Join or Union
– Phablo Raylan