我一直得到一个“通知:未定义的索引:做了”这个查询的错误,我不明白为什么......我更习惯于mysql,所以,也许语法错了?
这是php查询代码:
function get_demos() {
global $session;
$demo = array();
$result = pg_query("SELECT DISTINCT(did,vid,iid,value) FROM dv");
if(pg_num_rows($result) > 0) {
while($r = pg_fetch_array($result)) {
switch($r['did']) {
case 1:
$demo['a'][$r['vid']] = $r['value'];
break;
case 2:
$demo['b'][$r['vid']] = $r['value'];
break;
case 3:
$demo['c'][$r['vid']] = $r['value'];
break;
}
}
} else {
$session->session_setMessage(2);
}
return $demo;
}
当我在pg提示符下运行该查询时,我得到了结果:
"(1,1,1,"A")"
"(1,2,2,"B")"
"(1,3,3,"C")"
"(1,4,4,"D")"
"(1,5,5,"E")"
"(1,6,6,"F")"
"(1,7,7,"G")"
"(1,8,8,"H")"
"(1,9,9,"I")"
"(1,10,A,"J")"
"(1,11,B,"K")"
"(1,12,C,"L")"
"(1,13,D,"M")"
"(2,14,1,"A")"
"(2,15,2,"B")"
"(2,16,0,"C")"
"(3,17,1,"A")"
"(3,18,2,"B")"
"(3,19,3,"C")"
"(3,20,4,"D")"
"(3,21,5,"E")"
"(3,22,6,"F")"
"(3,23,7,"G")"