See a copy of the thinkphp to do Weibo development code, but some places do not read:
A . Code in the controller:
/*
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:
/*
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),