[英]how to use com.google.appengine.api.datastore.Text
i use Quercus to run php on google app engine and and i use below code to insert value to the GAE datastore (BigTable). 我使用Quercus在谷歌应用引擎上运行PHP,并使用下面的代码将值插入GAE数据存储区(BigTable)。
<?php
import com.google.appengine.api.datastore;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
$entity = new Entity("test");
$entity->setProperty('story',' --- more than 500 char ---');
$dataService = DatastoreServiceFactory::getDatastoreService();
$dataService->put($entity);
?>
but return flowing error because story value is more than 500 char. 但由于故事值超过500个字符,因此返回流动错误。
error:
com.caucho.quercus.QuercusException: com.google.appengine.api.datastore.Entity.setProperty: story: String properties must be 500 characters or less. Instead, use com.google.appengine.api.datastore.Text, which can store strings of any length.
i don't know any thing about java. 我不知道关于java的任何事情。 Does anyone have any idea how to use com.google.appengine.api.datastore.Text in my php code.
有谁知道如何在我的PHP代码中使用com.google.appengine.api.datastore.Text 。
thanks 谢谢
Will this work? 这会有用吗?
<?php
import com.google.appengine.api.datastore;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Text;
$entity = new Entity("test");
$TextValue = new Text(' --- more than 500 char ---');
$entity->setProperty('story',$TextValue);
$dataService = DatastoreServiceFactory::getDatastoreService();
$dataService->put($entity);
?>
Instead of passing in a string for the second parameter of 'setProperty', create a new com.google.appengine.api.datastore.Text and pass that in. 不要为'setProperty'的第二个参数传递字符串,而是创建一个新的com.google.appengine.api.datastore.Text并将其传入。
It looks like you should know how to do that. 看起来你应该知道如何做到这一点。
See the definition of 'setProperty' here: http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Entity.html 请在此处查看“setProperty”的定义: http : //code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Entity.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.