たとえば、1 つのビューで 3 つの異なるテーブルにデータを挿入する最良の方法は次のとおりです。
フービュー:
カードを追加し、プレーヤーを追加し、目標を追加します。
- 挿入クエリを使用していますか?
- 3つの異なるテーブルクラスを使用していますか?
- または、さらに良い方法がありますか?
joomlaの組み込み関数を使用してストアおよび更新機能を実行できるため、テーブルクラスを続行できます。続きを読む
function store()
{
//Get post data
$this->_data = $this->getPostData();
$row = &$this->getTable('model_name');
if (!$row->bind($this->_data))
{
$this->setError($this->_db->getErrorMsg());
return false;
}
if (!$row->check())
{
$this->setError($this->_db->getErrorMsg());
return false;
}
if (!$row->store())
{
$this->setError($this->_db->getErrorMsg());
return false;
}
$new_id = $this->_db->insertId();
if($new_id > 0)
$this->_data->id = $new_id;
return true;
}
以下のように投稿データを設定します
function getPostData()
{
$this->_data->id = JRequest::getVar('id', 0, 'POST');
$this->_data->field1 = JRequest::getVar('field1', '', 'POST' );
$this->_data->field2 = JRequest::getVar('field2', '', 'POST' );
return $this->_data;
}
ご不明な点がございましたら、お尋ねください。