0

这是我加载表格并以 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来获取有关加载的值是否是外键的信息?

4

1 回答 1

1

查看发布在此问题上的答案,您只需在迭代 foreach 时添加特定列所需的额外约束

类似的问题和多个答案

于 2013-10-21T13:50:06.237 回答