PDO语句的问题 - 一般错误

时间:2013-02-15 00:14:14

标签: php pdo

嘿伙计我有以下内容:

$newStatus = "Non-Active - Driver Chose Non-Compliance";

    $sql = "SELECT username,ATF FROM members WHERE username = 'test'";
    $getcsvuser = $DBH->prepare($sql);
    $getcsvuser->execute();
    while($row = $getcsvuser->fetch(PDO::FETCH_ASSOC)){

        $memusername = $row['username'];
        $memATF = $row['ATF'];
        if ($memATF != 0 || $memATF != "0")
        {
        $tsql = "SELECT username,status,memberview ,statuschangedate FROM csvdata WHERE memberview =:user";
        $tgetcsvuser = $DBH->prepare($tsql);
        $tgetcsvuser->execute(array(':user' => $memusername));
        while($trow = $tgetcsvuser->fetch(PDO::FETCH_ASSOC)){

            $csvstatus = $trow['status'];
            $csvusername = $trow['username'];
            $csvdate = $trow['statuschangedate'];
            echo $csvstatus;
            if($csvstatus == "Open" || $csvstatus == "Enrolled - Policyholder Follow-Up Required" || $csvstatus == "Enrolled - Employee Follow-Up Required" || $csvstatus == "Non-Active - Insurance Cancelled" || $csvstatus == "Non-Active, Unable to Monitor - Incidental Business use Exclusion" || $csvstatus == "Non-Active - Employee Not Covered Under Listed Policy" || $csvstatus == "Non-Active - PolicyHolder Cancelled Additional Interest")
            {
                try {
                $newsql = "update csvdata set status =:newstatus where statuschangedate < NOW() - INTERVAL :atf DAY AND username =:mem";
                $newgetcsvuser = $DBH->prepare($newsql);
                $newgetcsvuser->execute(array(':newstatus' => $newStatus, ':atf' => $memATF, ':mem' => $csvusername));
                while($qrow = $newgetcsvuser->fetch(PDO::FETCH_ASSOC)){
                    echo "working";
                }
                 } catch (PDOException $e) {
        print "Error!: " . $e->getMessage() . "<br/>";
        die();
    }
            }

        }
        }

    }

一切都很好,除非我进入try {} ..我得到一个错误说SQLSTATE [HY000]:一般错误。

我要做的是让语句检查statuschangedate,它的数据类型为yy-mm-dd。为了查看它是否超过了其成员的到期日,他们放下了,如果这样改变并更新该员工的状态。问题是这不起作用,我无法弄清楚原因。

我可以用一只手,非常感激!

大卫

0 个答案:

没有答案