我有一个MySQL查询正在执行选择但它没有被执行。 MySQL代码是00000

时间:2018-04-25 16:25:27

标签: php mysql pdo

我有一个正在执行select的MySQL查询但它没有被执行。 MySQL代码是00000.代码以前工作但现在无论我将查询更改为什么都不返回数据。代码如下。对此的任何帮助都将非常感激!

$lettersToPrintQuery = "SELECT DISTINCT
                                  Registration.RegNumber, 
                                  Registration.RunnerID
                              FROM 
                                  Registration
                                  LEFT JOIN People On People.RunnerID = Registration.RunnerID
                              WHERE
                                  Registration.CLUBID = :CLUBid
                                  AND
                                  Registration.CLUBDonationLetterNeeded = 1
                              ORDER BY
                                  People.LastName, People.FirstName, People.MI";
        if ($lettersToPrintQuery = $pdoLink->prepare($lettersToPrintSQL))
        {
             error_log("Log prepare");

            $runnersBindValues = "";
            $runnersBindValues[":clubid"] = 19;
            error_log("Bind Parameters: " . json_encode($runnersBindValues));
            if ($lettersToPrintQuery->execute($runnersBindValues))
            {
                error_log("Log execute");
                if ($lettersToPrintQuery->rowCount())
                {
                    error_log("Log row count");
                    $numDonations = $lettersToPrintQuery->rowCount();
                    $_SESSION['RUNNERSAdmin']['Reg']['Donations']['CLUBDonationLettersToPrint'] = array();
                    $_SESSION['RUNNERSAdmin']['Reg']['Donations']['CLUBDonationLettersMailingList'] = array();
                    while ($row = $lettersToPrintQuery->fetch(\PDO::FETCH_ASSOC))
                    {
                        error_log("donation reg numbers inside loop: " . $row["RegNumber"]);
                        error_log("donation runner ids inside loop: " . $row["RunnerID"]);
                        $_SESSION['RUNNERSAdmin']['Reg']['Donations']['CLUBDonationLettersToPrint'][] = $row["RegNumber"];
                        $_SESSION['RUNNERSAdmin']['Reg']['Donations']['CLUBDonationLettersMailingList'][] = $row["RunnerID"];

                    }
                }
            }
            else{
                error_log("Mysql error info: " . json_encode($pdoLink->errorInfo()));
            }
        }
        error_log("Donation reg numbers: " . $_SESSION['RUNNERSAdmin']['Reg']['Donations']['CLUBDonationLettersToPrint']);
        error_log("Donation runner id: " . $_SESSION['RUNNERSAdmin']['Reg']['Donations']['CLUBDonationLettersMailingList']);

error_log(" Log execute")未执行。所以它只是没有执行

1 个答案:

答案 0 :(得分:1)

$lettersToPrintQuery = "SELECT DISTINCT

应该是:

$lettersToPrintSQL = "SELECT DISTINCT