Skip to content
Advertisement

can you change the local dexie DB values of null to just a string with no value

so i update my dexie db with my sql db, but the problem is that some of the values are empty

THE PROBLEM IS THAT WHEN I WANT TO PRINT THE VALUE IN PHP IT PRINTS ALL THE VALUES AND THE ONES WHICH ARE “”null””…. how do i fix this??

i am using datatables and i have a few columns which are linked and i still need to see that lets say the fuel col has nothing “” but it musnt show null

db.fuel.put({                        
  department: data[i].department
});

Advertisement

Answer

this checks if the value coming from mysql is null then directly changes it to an empty string

            url: 'fuel_fetch_null',
            headers: { 'X-Requested-With': 'XMLHttpRequest' },
            success: function(data) {
                //fuel
                db = db_open();
                data = JSON.parse(data);
                var  datas = data.data;


                for (i in datas) {
                    if(datas[i].department == null){
                        datas[i].department = '';
                    }
                     db.fuel.put({
                        id: datas[i].id,
                        department: datas[i].department
                    });
                }
            }
        });
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement