【问题标题】:CodeIgniter Filling form inputs with table dataCodeIgniter 使用表格数据填充表单输入
【发布时间】:2013-07-06 03:03:56
【问题描述】:

我可以通过将 result() 更改为 result_array() 来消除第 29 行错误。但是 preg_match() 字符串问题依然存在。

型号:

function get_room_details($data_room_type = array() ) {
    $query = $this->db->query('SELECT rt_id, rt_name FROM room_type ORDER BY rt_name ASC');
    $this->db->query($query);

    if($query->num_rows()>0) {
        foreach($query->result() as $row) {
            $data_room_type[$row['rt_id']] = $row['rt_name'];
        }
    }
    return $data_room_type;
    echo "<pre>";
    print_r($data_room_type);
    echo "</pre>";
}

错误:

【问题讨论】:

    标签: php codeigniter model


    【解决方案1】:

    去掉这行,多余,会报错:

     $this->db->query($query);
    

    你已经创建了结果object(这个var包含结果,它不是查询字符串):$query = $this-&gt;db-&gt;query('SELECT rt_id, rt_name FROM room_type ORDER BY rt_name ASC');,然后你把它作为参数传递给查询方法——它会导致错误。

    【讨论】:

      猜你喜欢
      • 2015-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多