-1
有我的查詢字符串,有沒有關於bindParam的任何問題?Mysql查詢選項參數
$str = "select A.option_id,count(*) as sum
from tb_feedback A,tb_question B,tb_group C
where (A.question_id=B.id)
and (:question is null or B.id=:question)
and (B.group_num=C.id)
and (:group is null or C.name=:group)
and (:fromdate is null or A.date >= CAST(:fromdate AS DATE))
and (:todate is null or A.date <= CAST(:todate AS DATE))
group by A.option_id";
$sql = $this->conn->prepare($str);
$sql->bindParam(':question', $obj['question']);
$sql->bindParam(':group', $obj['group']);
$sql->bindParam(':fromdate', $obj['fromdate']);
$sql->bindParam(':todate', $obj['todate']);
優良似乎它沒有成功,爲什麼ü問? – Borik 2015-03-13 17:21:59
你爲什麼覺得有問題?你有錯誤嗎? – Mureinik 2015-03-13 17:31:33
@Mureinik耶,看起來不錯,但運行我的程序,它返回null,實際上有一些記錄存在於我的dasebase – 2015-03-13 17:37:47