jquery - Mysql表列不为空,但我需要在codeigniter中为空列

标签 jquery mysql codeigniter

很痛苦,表列不为空值。我的表列“值”不为空。因为我需要它。这就是为什么我将其设置为不为空。当我从其他第三方同步数据时,某些值为空,并且这种情况发生了。那么如果为null如何设置到列中。

这里我的 Controller 代码一切正常,只需要插入,如果为空则也插入空,但表列不需要设置为空。

$sync_history = array();
$sync_history['total_sync_record'] = $records['count'];
$sync_history['module'] = $records['module'];
$sync_history['sync_time'] =  $records['time'];
$sync_history['sync_by'] = $records['user'];
$sync_history['way'] = $records['way'];
$sync_history['sync_type'] = 'Manual';
$sync_history['operation_type'] = 'Insert';
$sync_history['value'] = $records['value'];

$this->db->insert('sync_data', $sync_history);

这是问题$sync_history['value']。如果可能的话,不要将 mysql 中的列更改为 null。

谢谢

最佳答案

Please check with this:

($records['value'] != null || $records['value'] != "") ? $records['value'] : "";

关于jquery - Mysql表列不为空,但我需要在codeigniter中为空列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52552801/

相关文章:

php - CodeIgniter DB Forge 向表中添加引擎和唯一键

javascript - 如何调用附加在div中的angularjs函数

php - 错误 #1050 表 'name' 已存在,而我有一个空数据库

Jquery 弹出菜单

javascript - 如何在 onclick 上更改选项项的文本

jquery - js/css : disable scrollbar but keep scroll position

MySQL 记录集 SUM() GROUP BY

javascript - jQuery - 将类添加到不同数量的 div

php - 如何将两个不同的字符串转换为日期并将其存储在 MySQL 数据库的单个列中?

php - 无法删除 index.php,自定义路由不起作用