Good afternoon everyone, before explaining a little more about the doubt I would like to make it clear that I am very lazy on the subject and, incredible as it may seem, I have been trying for weeks to solve this problem. Doubt: I would like to list some data from my DB in case the user would enter a date and the system would only list records containing that date as if it were a filter. After several tests I was able to do a simple list without any filter, follow the codes: (home.ts)
carregarProdutos(){
this.produtoProvider.getAll()
.then(data => {
this.produtos = data;
});
}
productos.ts (provider)
getAll() {
return new Promise(resolve => {
this.http.get(this.URL+'/produto').subscribe(data => {
resolve(data);
}, err => {
console.log(err);
});
});
}
Index.php
$app->get('/produto/', function() use ($app){
(new \controllers\Produto($app))->lista();
});
Controller product.php
public function lista(){
global $app;
$sth = $this->PDO->prepare("SELECT * FROM produtos");
$sth->execute();
$result = $sth->fetchAll(\PDO::FETCH_ASSOC);
$app->render('default.php',["data"=>$result],200);
}
As I said this code is working, however I can not do the variable transport in any way so it looks like this:
$sth = $this->PDO->prepare("SELECT * FROM produtos WHERE data= :data");
$sth ->bindValue(':data',$data);
Again I'm sorry, but I'm really lazy on the subject.