What should I do with the data for different tables in the same foreach in the Thinkphp3.2 template?

Source: Internet
Author: User

See a copy of the thinkphp to do Weibo development code, but some places do not read:
A . Code in the controller:

/*
    • Home View
      */

    1. function Index () {

             P (S (' Usermsg '. session (' UID ')));       Replace_weibo (' ADSF ');       P (C (' FILTER '));              $db =d (' Weibo ');       Gets the ID of the current user and the ID of all the current user's friends $uid = Array (the session (' UID '));/????              $where =array (' Fans ' =>session (' uid '));           if (isset ($_get[' gid ')) {$gid = I (' gid ', ' ', ' intval ');           $where [' gid ']= $gid;       $uid = ";       } $result =m (' follow ')->where ($where)->field (' Follow ')->select ();           if ($result) {foreach ($result as $v) {$uid [] = $v [' Follow ']; }}//combination where condition is the ID of the current user's own with the ID of the current user's concern friend $where = array (' UID ' =>array (' in ', $uid));//where condition can be              A two-dimensional array? Total number of statistics, for paging $count = $db->where ($where)->count ();//The total number of records that the query satisfies requirements $Page = new \think\page ($co UNT,20);//Instantiate the total number of incoming records for the paging class and the number of records displayed per page (20)//Paging data query Note the parameters of the limit method are to use the page class's Properties $limit = $Page->firstrow. ', '. $Page-       >listRows; $Page->setconFig (' Theme ', "%total_row% Records%first%%up_page%%now_page%/%total_page%%down_page%%end%");       $Page->setconfig (' prev ', ' prev ');              $Page->setconfig (' Next ', ' next page ');       Read all Weibo $result = $db->getall ($where, $limit);//getall () method is the//p ($result) in the driving expansion;       $this->page= $Page->show ();//pagination display output $this, Weibo = $result;          $this->display ();    }

      Two . Code in the view:

    
      
           
       
        
        
                                     
        
                                                                                                 __ROOT__/Uploads/Face/{$v.face}                        
        
                                     __PUBLIC__/Images/noface.gif                        
       
        " width='50' height='50'/>                                                
      
       

    》》》》》
    Here's the point: the user's Avatar $v.face don't know where it comes from.
    Weibo this table does not have a face column, nor does it see the code to read the information in another table,
    The structure of its Weibo table is this:

    The avatar information may be from this table:

    But the first page of this table is also only face50 face80 face180 and no face this column.

    Would you like to ask how it handles data from different tables in the same foreach?

    Original code from: Https://github.com/milkbobo/Thinkphp3.2.3-weibo

    Reply content:

    See a copy of the thinkphp to do Weibo development code, but some places do not read:
    A . Code in the controller:

    /*
    • Home View
      */

    1. function Index () {

             P (S (' Usermsg '. session (' UID ')));       Replace_weibo (' ADSF ');       P (C (' FILTER '));              $db =d (' Weibo ');       Gets the ID of the current user and the ID of all the current user's friends $uid = Array (the session (' UID '));/????              $where =array (' Fans ' =>session (' uid '));           if (isset ($_get[' gid ')) {$gid = I (' gid ', ' ', ' intval ');           $where [' gid ']= $gid;       $uid = ";       } $result =m (' follow ')->where ($where)->field (' Follow ')->select ();           if ($result) {foreach ($result as $v) {$uid [] = $v [' Follow ']; }}//combination where condition is the ID of the current user's own with the ID of the current user's concern friend $where = array (' UID ' =>array (' in ', $uid));//where condition can be              A two-dimensional array? Total number of statistics, for paging $count = $db->where ($where)->count ();//The total number of records that the query satisfies requirements $Page = new \think\page ($co UNT,20);//Instantiate the total number of incoming records for the paging class and the number of records displayed per page (20)//Paging data query Note the parameters of the limit method are to use the page class's Properties $limit = $Page->firstrow. ', '. $Page-       >listRows; $Page->setconFig (' Theme ', "%total_row% Records%first%%up_page%%now_page%/%total_page%%down_page%%end%");       $Page->setconfig (' prev ', ' prev ');              $Page->setconfig (' Next ', ' next page ');       Read all Weibo $result = $db->getall ($where, $limit);//getall () method is the//p ($result) in the driving expansion;       $this->page= $Page->show ();//pagination display output $this, Weibo = $result;          $this->display ();    }

      Two . Code in the view:

    
      
           
       
        
        
                                     
        
                                                                                                 __ROOT__/Uploads/Face/{$v.face}                        
        
                                     __PUBLIC__/Images/noface.gif                        
       
        " width='50' height='50'/>                                                
      
       

    》》》》》
    Here's the point: the user's Avatar $v.face don't know where it comes from.
    Weibo this table does not have a face column, nor does it see the code to read the information in another table,
    The structure of its Weibo table is this:

    The avatar information may be from this table:

    But the first page of this table is also only face50 face80 face180 and no face this column.

    Would you like to ask how it handles data from different tables in the same foreach?

    Original code from: Https://github.com/milkbobo/Thinkphp3.2.3-weibo

    index/home/model/commentmodel.class.php

    ' id ', ' content ', ' time ', ' wid ',//' UID ',
    One ' _type ' = ' left '
    12),
    ' UserInfo ' =>array (
    ' username ', ' face50 ' = ' face ', ' uid ',
    _on ' + ' Comment.uid = Userinfo.uid '
    16),

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.