Search code examples
phpgoogle-fusion-tables

zend google fusion table update


As anyone any idea on how to update a table in google fusion using Zend framework?

I can get the data:

$url = "https://www.google.com/fusiontables/api/query?sql=SELECT%20name%20FROM%201695591";
$data = $gdata->get($url);

$postcodes = $data->getRawBody();

But have no idea how to update a row ... I know I have to 'call' this url, but no idea how :

UPDATE table_id SET column_name = value {, column_name = value }* WHERE ROWID = row_id

Thank you


Solution

  • Try this class http://barahlo.semero.com/description/Zend_Gdata_Fusion.zip

    Example of usage:

    $client = Zend_Gdata_ClientLogin::getHttpClient('your_login_here@gmail.com', 'your_pass_here', 'fusiontables');
    
    $base = new Zend_Gdata_Fusion($client);
    
    
    $sql = "SELECT ROWID FROM 596524 WHERE id = 1;";
    $rowdata =  $base->query($sql)->get_array();
    print_r($rowdata);
    
    $newRowId = $base->insertRow('596524',array(
        'id' => time(),
        'name' => 'trird row',
        'added' => date('n/j/y'),
    ) );
    
    $base->updateRow(
        '596524', 
        array('name' => 'new first row'), 
        $rowdata[1][0] //ROWID from insert query
    );
    

    Oauth login for Zend_Gdata:

    $oauthOptions = array( 
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER, 
    'version' => '1.0', 
    'signatureMethod' => 'HMAC-SHA1', 
    'consumerKey' => $CONSUMER_KEY, 
    'consumerSecret' => $CONSUMER_SECRET 
    ); 
    
    $consumer = new Zend_Oauth_Consumer($oauthOptions); 
    $token = new Zend_Oauth_Token_Access(); 
    $client = $token->getHttpClient($oauthOptions,null);
    
    $base = new Zend_Gdata_Fusion($client);
    
    // ...
    

    Also, there is official php client library http://code.google.com/p/fusion-tables-client-php/