Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
Touxten committed Jul 15, 2022
1 parent ec8fdb0 commit c245868
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions psgdpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,10 @@ public function getCustomerNameById($id_customer)
*/
public function getAgeCustomer($id_customer)
{
$value = (int) Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getValue('SELECT AVG(DATEDIFF("' . date('Y-m-d') . ' 00:00:00", birthday))
return (int) Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getValue('SELECT TIMESTAMPDIFF(YEAR, birthday, CURDATE()) AS age
FROM `' . _DB_PREFIX_ . 'customer` c
WHERE active = 1
AND id_customer = ' . (int) $id_customer . '
AND birthday IS NOT NULL AND birthday != "0000-00-00" ' . Shop::addSqlRestriction());

return (int) floor($value / 365);
}
}

0 comments on commit c245868

Please sign in to comment.