我有一个在 php 中运行的查询。数据库是 SQL Server 2008。PHP 中的查询是:
"SELECT * FROM applicants WHERE applicants.families_id = '{$family_array['id']}'";
id$family_array
与families_id
. 结果我得到了一行。mssql_fetch_array
我使用该函数将该行保存到 PHP 中的数组中。当我打印这个数组时,我得到以下信息:
Array
(
[0] => 26
[id] => 21
[1] => 21
[user_id] => 21
[2] => Kristi
[mother_fname] => Kristi
[3] => Lochala
[mother_lname] => Lochala
[4] => Nathan
[father_fname] => Nathan
[5] => Lochala
[father_lname] => Lochala
[6] =>
[app_emergency] =>
[7] =>
[upload_mother_passport] =>
[8] =>
[upload_mother_visa] =>
[9] =>
[upload_father_passport] =>
[10] => 0
[upload_father_visa] => 0
[11] => nathan-lochala
[user_added_username] => nathan-lochala
[12] => Mar 19 2013 01:00:37:660PM
[user_added_date] => Mar 19 2013 08:48:00:000AM
[13] => 192.168.88.15
[user_added_ip] => 192.168.88.15
[14] =>
[user_updated_username] =>
[15] =>
[user_updated_date] =>
[16] =>
[user_updated_ip] =>
[17] => 21
[18] => nathan-lochala
[username] => nathan-lochala
[19] => b9a234cb37ce2b75d77befecabfa650e39489e0b
[hash_password] => b9a234cb37ce2b75d77befecabfa650e39489e0b
[20] => Nathan
[fname] => Nathan
[21] => Lochala
[lname] => Lochala
[22] => 2
[num_child] => 2
[23] => Mar 19 2013 08:48:00:000AM
[24] => 192.168.88.15
[25] =>
[26] =>
[27] => nathan-lochala@shk.qsi.org
[email] => nathan-lochala@shk.qsi.org
[28] => parent
[access] => parent
)
如果您注意到,index [0]
与相应的键值不匹配[id]
。为什么是这样?我已经使用 SQL Server 管理器运行了完全相同的查询,它按预期执行,但是当我在 PHP 中获取该数组时,只有第一个键值会倾斜。除了重新创建表格之外,我已经尝试了所有我能想到的方法。有任何想法吗?
编辑:运行 mssql_fetch_assoc() 给我以下结果:
Array
(
[id] => 21
[user_id] => 21
[mother_fname] => Kristi