Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 回程停止环路牵引_Php_Codeigniter - Fatal编程技术网

Php 回程停止环路牵引

Php 回程停止环路牵引,php,codeigniter,Php,Codeigniter,我有一个返回所有用户好友的函数,但只返回一行,而不是与查询关联的所有行 function getAllFriends($email){ $myid = $this->getStudentId($email); $this->db->where('aluno_id',$myid); $sql = $this->db->get('mutamba_amigos');

我有一个返回所有用户好友的函数,但只返回一行,而不是与查询关联的所有行

 function getAllFriends($email){

             $myid = $this->getStudentId($email);

             $this->db->where('aluno_id',$myid);
             $sql =  $this->db->get('mutamba_amigos');

             if($sql->num_rows() > 0){

                 foreach ($sql->result() as $r){
                     $this->db->where('id',$r->amizade_id);

                     $sql2 =  $this->db->get('mutamba_amizades');

                     if($sql2->num_rows() > 0){

                            foreach ($sql2->result() as $f){
                                $this->db->where('id',$f->aluno_id);
                                $sql3 = $this->db->get('alunos');
                                if ($sql3->num_rows() > 0) {

                                   // echo "<br> Model rows: ". $sql3->num_rows();
                                    return $sql3->result();
                                }else{

                                      return false;
                                }
                             } 

                        }

                 }


             }else{
                // echo 'nothing found';
                return false;
             }


         }
函数getAllFriends($email){ $myid=$this->getStudentId($email); $this->db->where('aluno\u id',$myid); $sql=$this->db->get('mutamba_amigos'); 如果($sql->num\u rows()>0){ foreach($sql->result()作为$r){ $this->db->where('id',$r->amizade_id); $sql2=$this->db->get('mutamba_amizades'); 如果($sql2->num\u rows()>0){ foreach($sql2->result()作为$f){ $this->db->where('id',$f->aluno\u id); $sql3=$this->db->get('alunos'); 如果($sql3->num\u rows()>0){ //echo“
模型行:”.$sql3->num_rows(); 返回$sql3->result(); }否则{ 返回false; } } } } }否则{ //回声“什么也没找到”; 返回false; } } 如果我注释
return$sql3->result();'并取消注释
echo“
模型行:”$sql3->num_rows()<代码>计数正确。我知道一定是return`停止循环操作。我怎样才能解决这个问题


任何帮助都将非常有用。

对,我创建了一个数组“friends”,并没有从
$sql3
返回结果,而是使用
array\u push($friends,$sql3->result())
在循环块之后返回了“friends”数组。如果有更直接的方法,请告诉我。我对mysql和php已经有点生疏了,所以我希望有其他的解决方案。谢谢。

这正是
返回的预期行为。它,半环,或任何地方。是否要从
$sql3
返回结果数组?yes@Michaelberkowski您正在为$sql2返回的每一行调用$sql3上的
result()
。您希望将$sql3的结果连接到单个2D数组并返回,还是作为行集的数组(3D)返回,其中每个外部数组都是$sql2的集合?不,我只需要上一次查询的结果