I have a very large matrix 1328x1328 and I'm trying to store the upper triangle (it is symmetrical) of it to the database as LONGTEXT.
In JavaScript I serialize it: JSON.stringify(matrix)
(serialized string length 16744056 characters) and send it to the server using ajax:
$.ajax({
type: "PUT",
url: 'post-user-matrix.php',
data: JSON.stringify(matrix),
contentType: "application/json"
});
It arrives to PHP with no problems, but from there I want to save it to the database table
u_id(INT) | matrix_json (LONGTEXT)
The PHP script that should send the data to the database look like this:
$user_id = getUserID();
$matrix = file_get_contents("php://input");
if ($insert_stmt = $mysqli->prepare("INSERT INTO users_matrix (u_id, matrix_json) VALUES (?,?)")) {
$null = NULL;
$insert_stmt->bind_param('is',$user_id, $null);
$matrixchunks = str_split($matrix, 8192);
for ($i=0 ; $i < count($matrixchunks) ; $i++) {
$insert_stmt->send_long_data(1, $matrixchunks[$i] );
}
$insert_stmt->execute();
}
I tried to use send_long_data relying on PHP documentation, but the script gives no errors and doesn't send anything to the database.