first of all, sorry for my bad english, and sorry if post answered, but I don't found it.
I want to "migrate" blob
field in mysqli
, so, I want to get_records and store it in other database (with multiple connections).
I have the next table:
id | name | data | timecreated
1 | Foo | BLOB | 1551863583
data could be a file(specially image, but not always)..
How should the insert in the database?
When I make the INSERT
statement the value of that column is null
.
A greeting!
EDIT: This is my code:
<?php
$con1 = mysqli_connect($con1_host, $con1_user, $con1_pass, $con1_bbdd);
$con2 = mysqli_connect($con2_host, $con2_user, $con2_pass, $con2_bbdd);
function get_records_sql($sql, $con) {
$ret = array();
if ($results = $con->query($sql)) {
while ($row = $results->fetch_array()) {
$ret []= $row;
}
$results->close();
}
return $ret;
}
// Get records from foo_bar connection1
$records = get_records_sql("SELECT * FROM foo_bar", $con1);
foreach ($records as $record) {
// Inserting records to foo_bar connection2
$sql = "INSERT INTO foo_bar (`name `, `data`, `timecreated`) VALUES ('{$record['name']}', '{$record['data']}', '{$record['timecreated']}')";
mysqli_query($con2, $sql);
$id = mysqli_insert_id($con);
}