Open ronakprogrammer opened 8 years ago
any update on this?
Yes you can do this with batch requests. See the README file for an example of performing batch requests.
The Google spreadsheet API works based on individual cells which are not related in any way to other cells in that row or column, also there is no concept primary keys etc. it's not a database. So you can't do an "INSERT IGNORE" as you would in MySQL fro example. You'll have to apply the logic in your application code.
@asimlqt Thanks for the response but the example in Readme is related to batch insert but here in this case I was looking for a way to get list feed based on query like this
$listFeed = $worksheet->getListFeed(array("sq" => "date = $date"));
Get all entries of specific date and update all entries of this date. Is this possiblle to achieve so?
@ronakprogrammer There's no easy way.
You can perform batch updates with a cell feed but you'll need to know the row number of the cells you're updating. If you're only fetching data for specific dates then that will not be possible.
I guess you'll have to find another way around it.
@asimlqt Ok in this case can you tell me is there any way I can query the Cell feeds based on particular date just like this below
$listFeed = $worksheet->getListFeed(array("sq" => "date = $date"));
I tried with Query getting cellfeed but no response, is there any way?
@ronakprogrammer
Do it like
$listFeed = $worksheet->getListFeed(array("sq" => 'date = "'.$date.'" '));
After that you need to call
$entries = $listFeed->getEntries();
if(empty($entries)){
// do in case of no records found
}
else{
// do in case if records found
}
@gauravjain028 I am already doing like that but this is something like loop each date and if data exist then update else insert that's still not batch update.I am trying to achieve like if I have 100 records and I already have data for 100 records in google sheet then I don't need to update 100 reords each time it should update batch of 100 rows in a single call.
Is there any way to batch update of the multiple data?
I have a data like this
$data = [ [ 'Date' => '2016-02-02', 'Name' => 'test', 'Email' => 'test@test.com', 'ContactNo' => '12345' ], [ 'Date' => '2016-02-03', 'Name' => 'test3', 'Email' => 'test3@test.com', 'ContactNo' => '12345' ], [ 'Date' => '2016-02-04', 'Name' => 'test4', 'Email' => 'test4@test.com', 'ContactNo' => '12345' ], ]
Like wise I have an array of 100 entries and I want to batch update the data and if there is no entry for specific date then need to insert.
hows this possible to achieve this?