PHP SQL multi-Table query paging

Source: Internet
Author: User

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

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.