2
我使用quercus作爲appengine。我嘗試保存一個長的PHP字符串(> 1000個字符),但appengine不會允許我作爲字符串只能容納500個字符。所以我嘗試使用appengine的文本數據類型。它讓我保存,但是,當我從PHP中檢索數據時,它會返回一個資源()類型而不是字符串。使用quercus在php中保存大字符串
讓我的代碼解釋:
<?php
$a = new Text("this is a long string that contains more than 1000 characters");
$b = "this is a long string that contains more than 1000 characters";
$e = new Entity('Article');
$e->setProperty('content', $a); // this works fine
// $e->setProperty('content', $b); // will complain as strlen($b) is > 500
$db = DatastoreServiceFactory::getDatastoreService();
$id = KeyFactory::keyToString($db->put($e)); // works ok, returns the ID of Entity saved
?>
現在,所有的罰款和花花公子,但是當我找回$ e的內容,它將返回我的資源()類型的數據。
<?php
$q = new Query('Article');
$ps = $db->prepare($q);
foreach($ps->asIterable() as $i) {
echo gettype($i->getProperty('content')); // this will echo Object, which when var_dump'd, gives me a resource() which is not convertible to php string, thus I can't get the human readable value
}
?>
有沒有什麼解決方法呢?任何幫助是極大的讚賞,因爲我一直在拉我的頭髮天...