简体   繁体   中英

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).

<?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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM