1 Public functionGet_search ($page=1){2 $slide=$_post[' Slide '];3 $page=Trim($page);4 $arr=$this->m->get_all ("Select a.* from ' Lx_z_news ' as a where a. ' title ' like '% ').$slide." % ' UNION ALL SELECT b.* from ' lx_z_product ' as B where B. ' title ' Like '% '.$slide." %‘ ");5 $row=Count($arr);6 $page 2=page ($page,$row, 10);7 $select _from=$page 2[' Select_from '];8 $select _limit=$page 2[' Select_limit '];9 $arr 1=$this->m->get_all ("Select ' A ' tbname,a.title,a.summary,a.id,a.c_time,a.status as thumb from ' lx_z_news ' as a where a. ' t Itle ' like '% '.$slide." % ' UNION ALL SELECT ' B ' tbname,b.title,b.summary,b.id,b.c_time,b.thumb from ' lx_z_product ' as B where B. ' title ' Like '% '.$slide." % ' limit$select _from,$select _limit");Ten One foreach($arr 1 as $key=>&$e){ A - $e[' title ']=Str_replace($slide, ' <i style= ' color:red ' > '.$slide.‘ </i> ',$e[' title ']); - } the unset($e); - - $this->assign ("Slide",$slide); - $this->assign (' Search_list ',$arr 1); + $this->assign (' Pagenav ',$page 2[' Pagenav ']); - $this->assign (' num ',$row); + $this->display ("search01.html"); A}
0: Multi-table UNION All does not go heavy 、、、、 union to weight
1: ' A ' tbname, ' B ' tbname to find out which table it is
2: Query result column fields must be the same
PHP SQL multi-Table query paging