开发者

Very strange PDO->bindparam behaviour php

The query below is running well and runs quite fast for what it does. However it is displaying some very strange behaviour as outlined below.

However in PHP it seems to decide by itself which ids it will work for. I am certain that the code is correct. I am using PD开发者_JS百科O in PHP and binding the variables as required.

So for instance if I pass it the author_id 600 it will work, but if I pass it the author_id 2 it won't work and brings back no records. But if I echo the query and paste it into MySQL and run it, it works for both the ids. It would seem that the PDO is failing to bind the variable on some ids. I have echoed the id variable and it does indeed contain the proper id.

Has anyone else experienced this behaviour? I find it very very unusual.

SELECT
GROUP_CONCAT(a.author_id) AS author_ids
FROM
references_final AS rf
INNER JOIN (reference_authors AS ra INNER JOIN authors_final AS a ON (ra.author_id = a.author_id))
ON (rf.reference_id = ra.reference_id)
GROUP BY rf.reference_id HAVING :author_id IN (author_ids) 


Hey I am having the same problem With BindParam and ID value in my PDO Statement

$retrieveUsersToken = $dataBase->prepare('SELECT TheUsersTable.token AS token, TheUsersTable.myID AS myID, 
FROM TheUsersTable INNER JOIN TheCategoryListTable ON TheUsersTable.myID = TheCategoryListTable.userID 
WHERE TheUsersTable.myID != :userID AND TheCategoryListTable.category = :category');

$retrieveUsersToken->bindParam( ':category', $_POST['category'], PDO::PARAM_STR);
$retrieveUsersToken->bindParam( ':userID', $_POST['creatorID'], PDO::PARAM_INT);

myID != userID never works neighter does TheCategoryListTable.category = :category when :category contain space Looks like the Inner Join is creating troube in both our situations.

It's not really an answer but maybe binValue works better.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜