0
我正在嘗試使用PHP將整行從mysql讀入NSMutableArray
。如何將PHP的mysql_fetch_array()轉換爲NSMutableArray? PHP - > Xcode
例PHP代碼
<?php
$con = mysql_connect("localhost", "username", "password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='smith'";
$result = mysql_query($sql,$con);
echo(mysql_fetch_array($result));
mysql_close($con);
?>
陣列的輸出類似:
Array
(
[0] => smith
[LastName] => smith
[1] => Adam
[FirstName] => Adam
[2] => California
[Address] => California
[3] => 22
[Age] => 22
)
我如何讀MySQL的該數組,並存儲爲NSMutableArray
?
到目前爲止,我只知道如何從PHP使用以下收到一個字符串:
//to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL: [NSURL URLWithString:strURL]];
//to receive the returned value
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding: NSUTF8StringEncoding];
但我不知道如何讀的數組轉換變成一隻NSMutableArray
。我花了數小時尋找,我找不到答案。我不希望使用JSON並堅持使用Mysql/PHP/Obj-c
。