我有这个功能加载从一个名为“客户”正常工作表中的数组,但我也希望它来检查,如果客户已经过期,如果是显示错误插入日期检查到功能
所以我有下面的代码来检查id_expiry_date是否结束,但我很难找出把它放在函数中的位置。试了几件事,但似乎打破了。请协助。
function customer_load_by_id($id)
{
$dbh = dbh_get();
$id = array();
$sql = 'select c.* ' .
'from customer c ' .
'where c.cust_id = (select max(cust_id) from customer where id = ?)';
$stmt = $dbh->prepare($sql);
$stmt->execute(array($id));
$r = $stmt->fetch();
if (!is_bool($r)) {
$fields = id_get_fields();
foreach ($fields as $field) {
$n = $field['name'];
$id[$n] = $r[$n];
}
}
dbh_free($dbh);
$exp_date = "$id_expiry_date";
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);
if ($expiration_date > $today) {
//continue happily
} else
{
//don't continue
}
return $id;
}
// One of the fields in the array above is id_expiry_date
把它dbh_free($胸径)之间','和'收益$ id;'然后回来一个关于它为什么会中断的问题。 – Jasen
确定编辑了代码,为什么它会中断? – Kilisi
看起来像$ id_expiry_date未初始化。你有没有收到任何错误信息? – Jasen