Good!
I am creating functions in PHP with the aim of returning the difference between the date TIMESTAMP
of the database and today's date, and for this I have created two functions:
function getRegistos()
{
$query = "SELECT *, DATEDIFF(NOW(),dataDeEntrada) as diferenca FROM 'equipamentos' WHERE 1";
$this->connect();
$res = $this->execute($query);
$this->disconnect();
return $res;
}
function getData()
{
$query = "SELECT (dataDeEntrada2), DATEDIFF(NOW(),dataDeEntrada2) as diferencaTotais FROM 'equipamentos' WHERE 1";
$this->connect();
$res = $this->execute($query);
$this->disconnect();
return $res;
}
% is used to fetch registrations and days elapsed, and getRegistos()
is only used to get the total days since the product was registered (because when the administrator updates a product the column DateEntry returns to 0) .
I do not know if it's possible to join the two or call them differently ...
include_once('DataAccess.php');
$da = new DataAccess();
$res = $da->getRegistos();
$res1 = $da->getData();
while($row = mysqli_fetch_object($res)){ ... }
But only returns getData()
. I also tried to do another while but this time with getRegistos()
which is the value returned by $res1
but nothing done.
I'm new to PHP and I think I'm just complicating.