views:

66

answers:

1

Is it possible to pull rows from a Google Docs spreadsheet using PHP?

In SQL I would use something like:

SELECT * FROM table WHERE field = 'value' LIMIT 1

Is there a way to do this? I've heard you are supposed to use a 'Zend' framework, but I haven't been able to figure that out either. Any help would be appreciated

+3  A: 

From the Zend_Gdata documentation:

<?php
  $query = new Zend_Gdata_Spreadsheets_ListQuery();
  $query->setSpreadsheetKey($spreadsheetKey);
  $query->setWorksheetId($worksheetId);
  $query->setSpreadsheetQuery('name=John and age>25');
  $listFeed = $spreadsheetService->getListFeed($query);
?>

And to setup the $spreadsheetService object:

<?php
  $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
  $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
  $spreadsheetService = new Zend_Gdata_Spreadsheets($client);
  $feed = $spreadsheetService->getSpreadsheetFeed();
?>

You'll need to download either the full Zend Framework, or the standalone Google Data library.

Tim Lytle
I'm getting a errorFatal error: Class 'Zend_Gdata_Spreadsheets_ListQuery' not found in
Cortopasta
Looks like you got some good answers from your other post, just make sure the 'Zend' directory is in your include path, then do `require_once('Zend/Gdata/Spreadsheets/ListQuery.php')`. Same goes for the other classes. Or just use the autoloader.
Tim Lytle