我希望从我的数据库中获取数据并将其插入到数组中以将其传递给我的Android应用程序。要提取的数据:
这些小屋都是符合严格的生态旅游规范的预制结构,以保留森林覆盖的原始特征和坚固性。当汽车停下来时,你会发现自己在一个平缓的山坡上,在厚厚的橡树和松树下。欢迎来到Shimla最好的度假胜地Shoghi的Aamod。 我们在Aamod Shoghi保存的另一个秘密就是我们的面包店。新鲜出炉的食物的香气会在每个醒着的时刻吸引你。如果您要求我们打包几个品种带回家,我们不会感到惊讶。我们声称是所有西姆拉餐厅中最好的面包师。 在Aamod度过的一天永远不会没有行动。清晨打开窗户,欣赏壮丽的景色和清新的空气。随着这一切开始你充满惊喜的一天。在我们庞大的草坪上享用团队早餐,或在我们众多设施的帮助下玩有趣的团队建设游戏。您可以在宽敞的会议室享受商务休闲。当您的团队忙于团队建设活动时,您可以通过我们专业维护的切片和果岭计划您的下一次领导休养胜利!
但是剧本每次都会崩溃。
$resort_name = $_POST['resort_name'];
$sql = "SELECT resort_desc from resorts where resort_name = :resort_name";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':resort_name', $resort_name, PDO::PARAM_STR);
$stmt->execute();
if($stmt->rowCount()){
$response["resort_desc"] = array();
$response["resort_desc"][0] = $stmt->fetch();
$response["success"] = 1;
} else {
$response["success"] = 0;
}
结果的大小是否太大?如果是这样,我怎样才能获得这些数据?
的var_dump( '响应') `
array(1) {
array(2) {
["resort_desc"]=>
string(1135) "The cottages are all pre-fabricated structures in-line with the strict norms of Ecotourism so as to retain the original character and ruggedness of the forest cover. As the car stops, you�ll find yourself on a gentle hill slope, under a thick cover of oak and pine trees. Welcome to Aamod at Shoghi, the finest resort of Shimla. Another of our best kept secrets at Aamod Shoghi is our bakery. The aroma of freshly baked goodies will entice you every waking hour. We won�t be surprised if you ask us to pack a few assortments to carry back home. We claim to be the best bakers in all of Shimla restaurants. A day at Aamod is never without action. Open your windows early morning for a majestic view and fresh air. And with this begins your day full of surprises. Have team breakfast in our sprawling lawns or play interesting team building games with the help of our multitude of facilities. You can have Business retreats in our spacious conference rooms. While your team is busy at team building activities you can plan your next leadership retreat over a game of golf on our professionally maintained chipping and putting greens!"
string(1135) "The cottages are all pre-fabricated structures in-line with the strict norms of Ecotourism so as to retain the original character and ruggedness of the forest cover. As the car stops, you�ll find yourself on a gentle hill slope, under a thick cover of oak and pine trees. Welcome to Aamod at Shoghi, the finest resort of Shimla. Another of our best kept secrets at Aamod Shoghi is our bakery. The aroma of freshly baked goodies will entice you every waking hour. We won�t be surprised if you ask us to pack a few assortments to carry back home. We claim to be the best bakers in all of Shimla restaurants. A day at Aamod is never without action. Open your windows early morning for a majestic view and fresh air. And with this begins your day full of surprises. Have team breakfast in our sprawling lawns or play interesting team building games with the help of our multitude of facilities. You can have Business retreats in our spacious conference rooms. While your team is busy at team building activities you can plan your next leadership retreat over a game of golf on our professionally maintained chipping and putting greens!"
}
}
["success"]=>
int(1)
}
答案 0 :(得分:0)
使用$stmt->fetch()
时,它会返回结果集,而不是单个值。
所以做一些像
$data = $stmt->fetch();
$response["resort_desc"][0] = $data["resort_desc"];