目前我有这个问题:
$qry = "SELECT platforms.PID
FROM user_profile
LEFT JOIN platforms
ON platforms.relaccount = user_profile.subkey
WHERE user_profile.UID = `".$data['id']."`";
$games = $this->db->select('main.APPID, games_other.name, games_other.logo')
->select('platforms.PID, platforms.name AS pname, platforms.logo AS plogo')
->select('('.$qry.') AS filt', null, FALSE)
->from('games_link AS main')
->join('games_platforms', 'games_platforms.APPID = main.APPID', 'left')
->join('platforms', 'platforms.PID = games_platforms.PID', 'left')
->join('games_other', 'games_other.APPID = main.GB_ID', 'left')
->like('games_other.name', $name)
->where('platforms.PID', 'filt')
->limit(15)
->get();
我试图根据输入字符串获取游戏但是通过用户拥有的平台进行过滤,但它会返回此错误:
Unknown column 'Cf9nHvOlaaLzFRegX2Il' in 'where clause'
SELECT `main`.`APPID`, `games_other`.`name`, `games_other`.`logo`, `platforms`.`PID`, `platforms`.`name` AS pname, `platforms`.`logo` AS plogo, (SELECT platforms.PID FROM user_profile LEFT JOIN platforms ON platforms.reaccount = user_profile.subkey WHERE user_profile.UID = `Cf9nHvOlaaLzFRegX2Il`) AS filt FROM (`games_link` AS main) LEFT JOIN `games_platforms` ON `games_platforms`.`APPID` = `main`.`APPID` LEFT JOIN `platforms` ON `platforms`.`PID` = `games_platforms`.`PID` LEFT JOIN `games_other` ON `games_other`.`APPID` = `main`.`GB_ID` WHERE `platforms`.`PID` = 'filt' AND `games_other`.`name` LIKE '%a%' LIMIT 15
Filename: response/update.php
我尝试过改变一些事情,但没有任何修复。
此外,由于我已经能够到达那里,它是否可以作为过滤器使用。子查询将返回多个。
答案 0 :(得分:1)
你有一个带有反引号的列值,如果它的INTEGER
,则它无效,应该是单引号或没有引号$qry = "SELECT platforms.PID
FROM user_profile
LEFT JOIN platforms
ON platforms.reaccount = user_profile.subkey
WHERE user_profile.UID = '".$data['id']."'";
答案 1 :(得分:1)
你的问题在这里:
WHERE user_profile.UID = `Cf9nHvOlaaLzFRegX2Il`
反引号,`,转义数据库对象(视图名称,表名,列名等)。
字符串值应使用单引号转义,'。
我会警惕连接值,如果可能的话,你应该将它们绑定在一起。