2016-07-06 76 views
0

我試圖使用谷歌的PHP API客戶端,完全融合。爲了創建表的參數設置是這樣的:什麼是PHP中的'list'變量類型?

$postBody = new Google_Service_Fusiontables_Table; 
$postBody->setName('Test'); 

我也應該至少設置一列這樣

$postBody->setColumns($columns); 

但文件說,$列應該有「名單」的價值。這是什麼意思? here it is 字符串和布爾值非常清楚,但列表是什麼?

根據Google s documentation, it的請求正文。什麼語法?什麼意思大括號,我怎樣才能設置$列? request body

+0

你確定你正在閱讀的PHP文件 – RiggsFolly

+0

沒有,但可以去看沒有PHP文檔 –

回答

0

這裏列的列表是類型array。列至少需要這些屬性:

  1. 塔的name
  2. 列的type( 「日期時間」, 「地點」, 「數字」 或 「STRING」)

當您使用谷歌PHP API客戶端一列由通過陣列傳遞他們預計的Google_Service_Fusiontables_Column

您可以直接設置所需的屬性實例構造函數:

new Google_Service_Fusiontables_Column(array('type'=>'STRING','name'=>'desiredColumName')); 

一個完整的創建表(2列)的是這樣的:

//create FusionTable-instance 
$table = new Google_Service_Fusiontables_Table; 

//set table-name 
$table->setName('myTableName'); 

//set required option isExportable 
$table->setIsExportable('true'); 

//set column(s) 
$table->setColumns(array(
          new Google_Service_Fusiontables_Column(array('type'=>'STRING', 
                     'name'=>'columnName')), 
          new Google_Service_Fusiontables_Column(array('type'=>'NUMBER', 
                     'name'=>'otherName')) 
         ) 
       ); 

//insert the table 
//$service is a Google_Service_Fusiontables-instance 
$result = $service->table->insert($table); 

//display Id of the new FusionTable 
echo $result->tableId; 
0

它看起來就像是一串字符串。列表不是PHP數據類型,雖然有一個不相關的函數叫做list()

+0

數組不合適,它給出了一個錯誤。我也嘗試過json編碼。 –

+0

var_dump()字段提供更多信息。 –

+0

什麼字段? $ columns是emty,我應該設置它 –

相關問題