返回错误数组codigniter的查询

mec1mxoz  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(413)

我正在尝试从数据库获取数据这里是查询

public function updating($id)
    {
        $uquery=$this->db->query(' SELECT * FROM `form` WHERE id='.$id);
        print_r($uquery);
        //return $request_data;

    }

但不是返回数组,而是返回以下内容:

CI_DB_mysqli_result Object ( [conn_id] => mysqli Object ( [affected_rows] => 1 [client_info] => mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $ [client_version] => 50012 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 6 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.5-10.1.16-MariaDB [server_version] => 50505 [stat] => Uptime: 250329 Threads: 1 Questions: 4886 Slow queries: 0 Opens: 40 Flush tables: 1 Open tables: 29 Queries per second avg: 0.019 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 353 [warning_count] => 0 ) [result_id] => mysqli_result Object ( [current_field] => 0 [field_count] => 6 [lengths] => [num_rows] => 1 [type] => 0 ) [result_array] => Array ( ) [result_object] => Array ( ) [custom_result_object] => Array ( ) [current_row] => 0 [num_rows] => [row_data] => )

为什么这根绳子要来?

2nbm6dog

2nbm6dog1#

你必须使用

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();

谢谢

roqulrg3

roqulrg32#

使用result_array();

public function updating($id)
    {
        $uquery=$this->db->query(' SELECT * FROM `form` WHERE id='.$id);
        $array =$uquery->result_array();
        print_r($array);

    }

相关问题