HTMLテーブルのアップグレード

ドキュメント

変更点

  • メソッド名とライブラリの読み込み方法など、小さな変更点のみです。

アップグレードガイド

  1. クラス内で、$this->load->library('table');$table = new \CodeIgniter\View\Table();に変更してください。

  2. その後、$this->tableから始まるすべての行を$tableに置き換える必要があります。例えば、echo $this->table->generate($query);echo $table->generate($query);になります。

  3. HTMLテーブルクラスのメソッド名はわずかに異なる場合があります。命名における最も重要な変更点は、アンダースコアを使用するメソッド名からキャメルケースへの変更です。バージョン3のset_heading()メソッドは、setHeading()になります。

コード例

CodeIgniterバージョン3.x

<?php

$this->load->library('table');

$this->table->set_heading('Name', 'Color', 'Size');

$this->table->add_row('Fred', 'Blue', 'Small');
$this->table->add_row('Mary', 'Red', 'Large');
$this->table->add_row('John', 'Green', 'Medium');

echo $this->table->generate();

CodeIgniterバージョン4.x

<?php

$table = new \CodeIgniter\View\Table();

$table->setHeading('Name', 'Color', 'Size');

$table->addRow('Fred', 'Blue', 'Small');
$table->addRow('Mary', 'Red', 'Large');
$table->addRow('John', 'Green', 'Medium');

echo $table->generate();