如何将来自 3 个不同输入字段的数据一起插入 codeigniter 中 mysql 数据库中 table 的一列中

How to insert data from 3 different input fields together in one column of table in mysql database in codeigniter

我想在我的数据库 table 的单列位置插入来自不同输入字段(如国家、州和城市)的数据。我现在有这样的领域。

+----------------+----------------+----------+
|    zipcode     |      city      |   state  |
+----------------+----------------+----------+
|     10954      |     Nanuet     |    NY    |
+----------------+----------------+----------+

但是,我想像这样插入数据。

+---------------------+
|      location       |
+---------------------+
| 10954 - Nanuet, NY  |
+---------------------+

如何在 codeigniter 中实现?

$ZIP  = $this->input->post('zipcode');
$CITY = $this->input->post('CITY');
$STATE = $this->input->post('STATE');
$location = $ZIP  .' - '.$CITY .' , '.$STATE ;

您现在可以插入该位置变量,您的模型查询;

$this->db->insert('tablename', array('location=>$locaiton'))