这是我的用于加载表格并在HTML table
中显示的脚本。
$fields = $this->db->list_fields($tableName);
$fieldData = $this->db->field_data($tableName);
$this->db->from($tableName);
$this->db->order_by($fields[0], "asc");
$query = $this->db->get();
$table = $query->result();
$columnsQ = $this->db->query("select count(column_name) from information_schema.columns where table_name = '".$tableName."'");
$columns = $columnsQ->row();
foreach($table as $row) {
echo "\t<tr class='value'>\n";
$colNr = 1;
foreach ($row as $tdVal) {
$colNr0 = $colNr-1;
$valType = $fieldData[$colNr0]->type;
$isForeign; // how to get info?
if($colNr==1) {
echo "\t\t<td data-valType='$valType' class='id'>$tdVal</td>\n"; }
else {
echo "\t\t<td data-isForeign='$isForeign' data-valType='$valType' data-colNr='$colNr'>$tdVal</td>\n"; }
$colNr++;
}
}
</table>";
$isForeign
下应该有什么查询来获取有关加载的值是否为外键的信息?
答案 0 :(得分:1)
看看这个问题上发布的答案,你需要在迭代你的foreach时添加你的特定列所需的额外约束