[英]PHP ibase query
i want to use PHP for internet service in my IOS 7 application. 我想在我的IOS 7应用程序中将PHP用于Internet服务。 I've tried to generate an code for receiving objects from a Firebird database.
我尝试生成用于从Firebird数据库接收对象的代码。 My Code bellow:
我的代码如下:
<?php
$host = 'xxx';
$username = 'xxx';
$password = 'xxx';
$conn = ibase_connect($host, $username, $password) or
die ("Verbindung fehlgeschlagen");
$arr = array();
$data = array();
$stmt = "select * from xxx";
$sth = ibase_query($conn, $stmt);
while ($row = ibase_fetch_object ($sth)) {
$data['ID'] = $row->ID;
$data['VON'] = $row->VON;
$data['AN'] = $row->AN;
$data['BETREFF'] = $row->BETREFF;
$data['DATUM'] = $row->DATUM;
$data['KOMMISSIONSNR'] = $row->KOMMISSIONSNR;
$data['NACHRICHT'] = $row->NACHRICHT;
$data['GELESEN'] = $row->GELESEN;
$data['GEANTWORTET'] = $row->GEANTWORTET;
$data['STATUS'] = $row->STATUS;
$data['AUFTRAG'] = $row->AUFTRAG;
$arr[] = array($data);
}
echo json_encode($arr);
?>
By calling the code in Safari-browser no values or arrays be returned. 通过在Safari浏览器中调用代码,不会返回任何值或数组。 If giving an Key like 1 (
echo json_encode($arr[1]);
) an array on the browser will be shown. 如果给出一个像1的键(
echo json_encode($arr[1]);
),将显示浏览器上的数组。
How can i show the whole array with all keys? 如何显示带有所有键的整个阵列? I should add that i want to use the results from my ibase-query as NSDictionary in the application.
我应该补充一点,我想将ibase-query的结果用作应用程序中的NSDictionary。
And which framework is the best for encoding the PHP-Array to IOS? 哪种框架最适合将PHP-Array编码为IOS? I've tried to use JSONDictionaryExtensions, but don't know if it's the right for this Code.
我尝试使用JSONDictionaryExtensions,但不知道此代码是否合适。
i hope you can help me. 我希望你能帮助我。
Sorry for my bad english. 对不起,我的英语不好。
I'm not sure why you are putting the $data
array into another array. 我不确定为什么要将
$data
数组放入另一个数组。 You can skip that step. 您可以跳过该步骤。
When you echo json_encode($data)
you encode the array as JSON, so that is what your iOS application gets and what it needs to decode. 当您
echo json_encode($data)
时,会将数组编码为JSON,这就是iOS应用程序获得的内容以及需要对其进行解码的内容。 Decoding JSON into an NSArray or NSDictionary has been asked many times here on StackOverflow, like this question . 在StackOverflow上已多次要求将JSON解码为NSArray或NSDictionary,就像这样的问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.