我有以下代码:
<?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();
}
?>
它应该返回329但是它在var_dump中返回null。
Mysql表Wg_Attack_troop,表明表中存在329:
wg_attack table:
正如您所看到的,代码是正确的,那为什么它会在var_dump
中返回NULL?
编辑NR1:
Var_dump:string(5) "80271" string(2) "32" NULL
80271是$ kaimo_id 32是$ troop_id
编辑NR2:phpmyadmin返回此
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