下面是获取一行中所有列的查询
$STH = $DBH->db->prepare("SELECT * FROM Settings");
$STH->execute();
$STH->setFetchMode(PDO::FETCH_ASSOC);
$str = '';
while ($row = $STH->fetch())
{
foreach($row as $key => $value)
{
$str .= '<div>'.$key.' => '.$value.'</div>';
}
}
这个是为了得到列的扩展信息(包括 comment
)
$STH = $DBH->db->prepare("SHOW FULL COLUMNS FROM Settings");
$STH->execute();
$STH->setFetchMode(PDO::FETCH_ASSOC);
\* the same php code *\
我可以将这两个sql查询组合起来同时获得以下数据吗
`FieldName`, `FieldValue`, `CommentValueOfColumn`
' ' '
设置表示例
Columns -> | PrintImage | SettMinus | HasChat . . .
--------------------------------------------
Values -> 0 1 1 . . .
还有其他数据 Comment
列的名称。所以我想选择数据:
PrintImage, 0 , Comment of PrintImage;
SettMinus, 1 , Comment of SettMinus;
HasChat, 1 , Comment of HasChat;
.....................................
and so on.
1条答案
按热度按时间yvgpqqbh1#
这将为您提供列名、列值和注解。但是,您可以使用php获取valuearray[ordinal_position]的值,您还需要在concat_ws之后复制/粘贴其余的列名。
同样,我不能在mysql中做所有的事情,所以它需要phpcodes的帮助才能从数组中获得准确的值。