我正在尝试从数据库获取数据 这是查询
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<th>Method</th>
<th>Expires</th>
<th>Actions</th>
</tr>
<tr>
<td>Card Info</td>
<td>Expiration</td>
<td>
<form class="sg-inline-form" method="post" action="">
<input type="hidden" name="sg_customer_id" value="customerID1">
<input type="hidden" name="sg_card_id" value="cardID1">
<a href="#" class="set-default">Set As Default</a>
<a href="#" class="delete-card">Delete</a>
</form>
</td>
</tr>
<tr>
<td>Card Info</td>
<td>Expiration</td>
<td>
<form class="sg-inline-form" method="post" action="">
<input type="hidden" name="sg_customer_id" value="customerID2">
<input type="hidden" name="sg_card_id" value="cardID2">
<a href="#" class="set-default">Set As Default</a>
<a href="#" class="delete-card">Delete</a>
</form>
</td>
</tr>
</table>
但不是返回数组,而是返回以下内容:
public function updating($id)
{
$uquery=$this->db->query(' SELECT * FROM `form` WHERE id='.$id);
print_r($uquery);
//return $request_data;
}
为什么这个字符串要来?
答案 0 :(得分:0)
使用result_array();
public function updating($id)
{
$uquery=$this->db->query(' SELECT * FROM `form` WHERE id='.$id);
$array =$uquery->result_array();
print_r($array);
}
答案 1 :(得分:0)
您必须使用
1) ->result_array() to get result data in array format
2) ->result() to get result data in object format
3) ->row() to get single result data in object format
4) ->row_array() to get single result data in array format
e.g $data = $this->db->query(' SELECT * FROM `form` WHERE id='.$id)->result_array();
谢谢