du21064 2014-05-17 16:07
浏览 10

为什么Mysql没有正确返回结果?

I have the following code:

    <?php
function GetSumPresentTroop3($kaimo_id, $troop_id){ // ZN kodas
global $db, $wg_village, $user;
$underaway = 0;

$sql="SELECT 
            wg_attack_troop.id
        FROM
            wg_attack ,
            wg_attack_troop
        WHERE
            wg_attack.id =  wg_attack_troop.attack_id AND
            wg_attack.status = '0' AND
            wg_attack.village_attack_id =  '".$kaimo_id."' AND
            wg_attack_troop.troop_id =  '$troop_id'
        GROUP BY 
            wg_attack_troop.id";

$db->setQuery($sql);
return $db->loadResult();
}
?>

And it should return 329 but insteed it returns a null in var_dump.

Mysql table Wg_Attack_troop which shows that 329 exists in the table:

enter image description here

wg_attack table:

enter image description here

As you can see code is correct, then why does it return a NULL in var_dump?

EDIT NR1: Var_dump: string(5) "80271" string(2) "32" NULL

80271 is $kaimo_id 32 is $troop_id

Edit NR2: phpmyadmin returns this

SELECT wg_attack_troop.id
FROM wg_attack, wg_attack_troop
WHERE wg_attack.id = wg_attack_troop.attack_id
AND wg_attack.status = '0'
AND wg_attack.village_attack_id = '80271'
AND wg_attack_troop.troop_id = '32'
GROUP BY wg_attack_troop.id
LIMIT 0 , 30
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题