2016-07-06 74 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,我应该设置它 –

相关问题