Welcome Guest, Not a member yet? Register   Sign In
going from json_decode to insert_batch
#1

(This post was last modified: 04-15-2018, 05:29 PM by richb201.)

I am getting back a buffer from a chrome extension via xhr. I take the buffer and use json_decode. Here is an example of the buffer called $json after json_decode:

[{"email":"[email protected]"},{"Date_0":"","BusinessC_0":"choose","Project_0":"choose","Activity_0":"choose","RecordId_0":"0","Date_1":"","BusinessC_1":"choose","Project_1":"choose","Activity_1":"choose","RecordId_1":"0","Date_2":"","BusinessC_2":"choose","Project_2":"choose","Activity_2":"choose","RecordId_2":"0","Date_3":"","BusinessC_3":"choose","Project_3":"choose","Activity_3":"choose","RecordId_3":"0","Date_4":"","BusinessC_4":"choose","Project_4":"choose","Activity_4":"choose","RecordId_4":"0","Date_5":"","BusinessC_5":"choose","Project_5":"choose","Activity_5":"choose","RecordId_5":"0","Date_6":"","BusinessC_6":"choose","Project_6":"choose","Activity_6":"choose","RecordId_6":"0","Date_7":"","BusinessC_7":"choose","Project_7":"choose","Activity_7":"choose","RecordId_7":"0","Date_8":"","BusinessC_8":"choose","Project_8":"choose","Activity_8":"choose","RecordId_8":"0","Date_9":"","BusinessC_9":"choose","Project_9":"choose","Activity_9":"choose","RecordId_9":"0","Date_10":"","BusinessC_10":"choose","Project_10":"choose","Activity_10":"choose","RecordId_10":"0","Date_11":"","BusinessC_11":"choose","Project_11":"choose","Activity_11":"choose","RecordId_11":"0","Date_12":"","BusinessC_12":"choose","Project_12":"choose","Activity_12":"choose","RecordId_12":"0","Date_13":"","BusinessC_13":"choose","Project_13":"choose","Activity_13":"choose","RecordId_13":"0","_RowCount":14}]

The first array element is the email address of the user that I am using as the key, and I can get that fine. The problem is that I want to log all this information to a table with 



    $this->db->insert_batch('activity_log', $json,14);

I actually want to append 14 separate records to the table, all with that same email address. But as you can see, the second element of the array is an object, that I can't really break up. I though about using a for loop but I don't think that will work. I have attached the structure of the table where I am trying to log this info.

Attached Files
.pdf   localhost _ 127.0.0.1 _ substantiator _ activity_log _ phpMyAdmin 4.5.1.pdf (Size: 97.03 KB / Downloads: 44)
proof that an old dog can learn new tricks
Reply


Messages In This Thread
going from json_decode to insert_batch - by richb201 - 04-15-2018, 05:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB