繁体   English   中英

Codeigniter foreach 不起作用

[英]Codeigniter foreach doesn't work

我有这个代码。编译器没有进入 foreach。 我不知道为什么? 虽然我在其他函数中编写了这个 foreach,但请任何人帮助我。
在模型中

public function getting_profile_check($u)
{
    $this->db->where('login_name', $u);


    return $this->db->get('profile_check');

}

并在控制器中

public function get_profile_check($user)
{
    echo"i in get profile check";
    $d=$this->login_m->getting_profile_check($user);

    $data=array('check_res'=>$d,'first_time'=>"no");

    foreach($d->result() as $field)
        { 
        echo"i in for each in get";
          $image=$field->image_c;

          $view=$field->overview_c;
          $certi=$field->certi_c;
          $edu=$field->edu_c;
          $hopp=$field->hopp_c;
          $lang=$field->lang_c;
           echo"session".$image."   " .$edu;

        }


    }

尝试这个

在控制器中

public function get_profile_check($user)
{
    echo"i in get profile check";
    $d = $this->login_m->getting_profile_check($user);

    $data=array('check_res'=>$d,'first_time'=>"no");

    foreach($d as $field)
    { 
        echo"i in for each in get";
        $image=$field->image_c;

        $view=$field->overview_c;
        $certi=$field->certi_c;
        $edu=$field->edu_c;
        $hopp=$field->hopp_c;
        $lang=$field->lang_c;
        echo"session".$image."   " .$edu;

    }
}

在模型中

public function getting_profile_check($u)
{
    $this->db->select("*");
    $this->db->where('login_name', $u);
    $query = $this->db->get('profile_check');
    $result = $query->result_array();
    return $result;
}

在模型中做这样的事情:

public function getting_profile_check($u)
{

   $this->db->select('*')
            ->from('profile_check')
            ->where('login_name', $u);


   $query = $this->db->get();
   if($query->num_rows > 0){
       return $query->result_array();
    }

}

在控制器中:

public function get_profile_check($user)
{
   echo"i in get profile check";

   $d=$this->login_m->getting_profile_check($user);


    foreach ($d as $row ) {

        echo $row['name_of_table_column'];
    }


}

模型

public function getting_profile_check($u)
{
   $this->db->where('login_name', $u);
   return $this->db->get('profile_check')->result();
}

控制器

public function get_profile_check($user)
{
   echo"i in get profile check";
   $d=$this->login_m->getting_profile_check($user);

   foreach ($d as $row ) 
   {
        echo $row->name_of_table_column;
   }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM