-1

$valid是一个数组,$createdon并且$days从数组中获取日期值。我的选择查询不适用于这些PHP变量的日期值,请解决它。

function checkexpiretime($valid)
    {
        $db = &JFactory::getDBO();
        foreach($valid as $validity)
        {
             echo $createdon=$validity->CreatedOn;
             echo $days=$validity->days;
        }
        echo $query="SELECT * FROM jos_generatekey WHERE CreatedOn BETWEEN DATE_ADD('".$createdon."',".INTERVAL $days DAY.")". "AND CURDATE()"; 
        $db->setQuery($query);
        $checkexpire = $db->loadObjectList();
        print_r($checkexpire);
        return $checkexpire;
    }
4

1 回答 1

0

查询应该是这样的:

$query= "SELECT * FROM jos_generatekey WHERE CreatedOn BETWEEN DATE_ADD('".$createdon."',INTERVAL ". $days ." DAY) AND CURDATE()";
于 2012-08-09T05:58:56.417 回答