如何使用 com.google.appengine.api.datastore.Text
我使用 Quercus 在 google 应用引擎上运行 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);
?>
但返回流动错误,因为故事值超过 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.
我对java一无所知。 有谁知道如何使用 com.google.appengine.api.datastore.Text 在我的 PHP 代码中。
谢谢
i use Quercus to run php on google app engine and and i use below code to insert value to the GAE datastore (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.
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.
Does anyone have any idea how to use com.google.appengine.api.datastore.Text in my php code.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这行得通吗?
Will this work?
不要为“setProperty”的第二个参数传入字符串,而是创建一个新的 com.google.appengine.api.datastore.Text 并将其传入。
看来您应该知道如何执行此操作。
请参阅此处“setProperty”的定义:http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Entity.html
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.
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