我在控制器中遍历查询结果,然后做些处理。
$sql="select CC from XXX";
$db = M();
$rs= $db->query($sql); ////////遍历RS
foreach ($rs as $key => $value)
{
//获取每条记录的"CC"字段的值
$CC= $value; //不成功!
$CC= $value[1]; //不成功!
$CC= $value[0]; //不成功!
$CC= ?? //////////////help!!!!!
}
foreach ($rs as $value)
{
//获取每条记录的"CC"字段的值
$CC= $value; //不成功!
$CC= $value[1]; //不成功!
$CC= $value[0]; //不成功!
$CC= ?? //////////////help!!!!!
}
$rs= $db->query($sql); ////////遍历RS
print_r($rs);
贴出结果
array(33) (
[0] => array(1) (
[column_name] => (string) ID
)
[1] => array(1) (
[column_name] => (string) UserName
)
[2] => array(1) (
[column_name] => (string) PSW
)
[3] => array(1) (
[column_name] => (string) NickName
)
print不知道在哪看结果,鼠标移动过去显示这些东西的值
我的语句就是查询某个表的所有列的名称,然后把名称取出来再加工
foreach ($rs as $value)
{
echo $value['column_name'];
}
OK了,谢谢大神