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