我有一张要插入多个国家/地区的汇率表。
这是我的表格
<? form_open_multipart('exchange/create')
?>
<input type="text" name="user[0][ExchangeRateDate]"/>
<input type="text" name="user[0][CountryId]"/>
<input type="text" name="user[0][CashSelling]"/>
<input type="text" name="user[0][CashBuying]"/>
<input type="text" name="user[0][TransferSelling]"/>
<input type="text" name="user[0][TransferBuying]"/>
<input type="text" name="user[0][InsertDate]"/>
<input type="text" name="user[0][Status]"/>
<input type="text" name="user[1][ExchangeRateDate]"/>
<input type="text" name="user[1][CountryId]"/>
<input type="text" name="user[1][CashSelling]"/>
<input type="text" name="user[1][CashBuying]"/>
<input type="text" name="user[1][TransferSelling]"/>
<input type="text" name="user[1][TransferBuying]"/>
<input type="text" name="user[1][InsertDate]"/>
<input type="text" name="user[1][Status]"/>
<input type="submit" value="insert exchange" class="btn"/>
</form>
她是当前表格的模型代码
public function set_exchange() {
$data = array('ExchangeRateDate' => $this -> input -> post('ExchangeRateDate'),
'CountryId' => $this -> input -> post('CountryId'),
'CashSelling' => $this -> input -> post('CashSelling'),
'CashBuying' => $this -> input -> post('CashBuying'),
'TransferSelling' => $this -> input -> post('TransferSelling'),
'TransferBuying' => $this -> input -> post('TransferBuying'),
'InsertDate' => $this -> input -> post('InsertDate'),
'Status' => $this -> input -> post('Status'));
return $this -> db -> insert('exchange_rate', $data);
}
最后这是控制器代码
public function create() {
$this -> load -> helper('form');
$this -> load -> library('form_validation');
$data['title'] = 'Create a news exchange rate';
$this -> form_validation -> set_rules('ExchangeRateDate', 'ExchangeRateDate', 'required');
$this -> form_validation -> set_rules('CountryId', 'CountryId', 'required');
$this -> form_validation -> set_rules('CashSelling', 'CashSelling', 'required');
$this -> form_validation -> set_rules('CashBuying', 'CashBuying', 'required');
$this -> form_validation -> set_rules('TransferSelling', 'TransferSelling', 'required');
$this -> form_validation -> set_rules('TransferBuying', 'TransferBuying', 'required');
$this -> form_validation -> set_rules('InsertDate', 'InsertDate', 'required');
$this -> form_validation -> set_rules('Status', 'Status', 'required');
$this -> all -> set_exchange();
$this -> load -> view('admin/exchange/create');
}
表结构
ExchangeRateId
ExchangeRateDate
CountryId
CashSelling
CashBuying
TransferSelling
TransferBuying
InsertDate
Status
这个想法是一切正常我插入一个新行数据进入我的数据库但在这里我想插入不止一行只有ID不重复但其他是,所以我使用的表格来自其他卡住的溢出但它不工作
分享你的知识
提前问好……