0

this query does not return due to a datetime search. How to use bind_param in datetime? thanks

$offset = ($pagina - 1)*2;
$date = date('Y-m-d H:i:s', time());
$last30days = date('Y-m-d', strtotime($date . ' -30 day'));
$prepare = $conn->prepare('SELECT `pedido`.`numero`, `pedido`.`dataCriacao`, `clientes`.`nome`, `pedido`.`totalvenda`, `pedido`.`situacao` 
                                FROM `pedido`
                                INNER JOIN `clientes` ON `clientes`.`codigo` = `pedido`.`clienteCodigo`
                                WHERE `pedido`.`dataCriacao` > :tempo
                                LIMIT :offset,2 
                            ');
    $prepare->bindValue(':tempo', $last30days, PDO::PARAM_STR);
    $prepare->bindParam(':offset', $offset, PDO::PARAM_INT);
    $prepare->execute();
  • 1
    There is nothing special in binding a datetime. It is bound the same way as any other variable. If your query returned no results it means there is either an error or no data to match the input parameters – Your Common Sense Nov 02 '20 at 16:15
  • What exactly do you mean by "due to a datetime search"? What have you tried to debug your problem? – Nico Haase Nov 20 '20 at 12:24

0 Answers0