I'm currently following the steps in the official api font . / p>
And in the current state of the project, I'm getting information from the table, changing and inserting data, without errors.
However, I would like to do a bulk insert in my table.
This is my code
$array = array();
foreach ($objects as $object) {
array_push(
$array,
"('".$object->lat.",".$object->lng."','".$object->other->lat.",".$object->other->lng."')"
);
}
$values = implode(",", $array);
$client = new Google_Client();
$tableId = "TableId";
$client->useApplicationDefaultCredentials();
$client->setScopes('https://www.googleapis.com/auth/fusiontables');
$service = new Google_Service_Fusiontables($client);
$service->query->sql("INSERT INTO ".$tableId." ('Location', 'City Location') VALUES ".$values); // I'm sorry, I forgot.
When I try to insert only one record with the same code, it works
This is my variable sql
when you have more than one record:
INSERT INTO TableId
('Location', 'City Location')
VALUES
('88.064342,-50.280747','-8.77,-36.62'),
(-55.781345,-69.294770','-28.24,-48.67'),
('14.696452,-26.844802','-19.92,-43.17')
Api returns the following error:
{
"error":{
"errors":[
{
"domain":"fusiontables",
"reason":"badQueryCouldNotParse",
"message":"Invalid query: Parse error near ',' (line 1, position 92).",
"locationType":"parameter",
"location":"q"
}
],
"code":400,
"message":"Invalid query: Parse error near ',' (line 1, position 92)."
}
}