dongzuo7166 2013-02-14 14:23
浏览 167

PHP使用Codeigniter中的get_where子句不传递数据

Hi All I'm new to Codeigniter, I'm trying to get all data relating to the account_id passed from a previous page.

I'm passing the account_id but not passing the name field associated with the account_id. The name field is blank.

I'm getting an error:

Here is my code for the controller:

function input($account_id = '', $name = ''){
   if((int)$account_id > 0){
      $query = $this->db->select('name', $name);
      $query = $this->db->get_where('db_accounts', array('account_id' => $account_id));

      $data['account'] = $query;
      $data['fname']['value']   = $name;
      $data['faccount_id']['value'] = $account_id;
      $data['name']        = '';
      $data['account_id']  = '';
  }

  $this->load->view('manage/input',$data);      
}

Here is my input view form:

<?php

   $data = array(
          'name'  => $fname['value'],
          'account_id' => $faccount_id['value']
        );

echo '<form action="/manage/edit" method="post" accept-charset="utf-8">';
echo form_hidden($data);

echo $account_id .' Account ID'.
    form_input($faccount_id); 
echo $name .' Name'.
    form_input($fname); 

$data = array('name' => 'submit', 'value' => 'Update Account', 'class' => 'submit');
echo form_submit($data);

  ?>
 <?php echo form_close(); ?>
  • 写回答

3条回答 默认 最新

  • dongqiao3214 2013-02-14 14:25
    关注

    i believe get_where just preps your query

    $query->row_array() should return your result as an array

    $query = $this->db->get_where('db_accounts', array('account_id' => $account_id));
    $result = $query->row_array();
    

    For the second part of your question it looks like there is a lot going on. What is the value of $name in your input function? Are you actually passing a value to input? Make sure that name is set in your input function or else it will just be an empty string.

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)