HTMLテーブルのアップグレード
ドキュメント
変更点
メソッド名とライブラリの読み込み方法など、小さな変更点のみです。
アップグレードガイド
クラス内で、
$this->load->library('table');
を$table = new \CodeIgniter\View\Table();
に変更してください。その後、
$this->table
から始まるすべての行を$table
に置き換える必要があります。例えば、echo $this->table->generate($query);
はecho $table->generate($query);
になります。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();