ZF Framework DB Class pagination sample sharing _php Tutorial

Source: Internet
Author: User
This article mainly introduces the ZF Framework DB class pagination example, the code is very simple, you can look at the comments to use the

The pagination sample code for the ZF framework is as follows: ' 127.0.0.1 ', ' username ' = ' root ', ' password ' = ' 111 ', ' dbname ' = ' test ', ' profiler ' = ' true ');//Tell Zen The database and database configuration information that the d_db class operates $db = Zend_db::factory (' Pdo_mysql ', $Config); Executes the encoding statement $Db, query ("Set names UTF8");//-----------------------------------------------//Use the Fetchone () method to derive the total number of bars in the table $Total = $Db, Fetchone ("SELECT count (*) from Gongsi");//define the number of bars per page $b = 50;//The total page $ A = ceil ($Total/$B); -----Next for a series of query tables, take result sets, pagination and other operations $select = $Db->select (); $Select, from (' Sanguo ', Array (' S_sheng as province ', ' Sum (s_ Gongzi) as total wages ', ' min (s_gongzi) as minimum wage ', ' max (S_gongzi) as maximum wage ', ' avg (S_gongzi) as average salary ') '//$Select, Where (' S_gongz i>=3000 ');//$Select Where ("s_sheng= ' Hebei '");//$Select Order (' S_sheng ASC ');//$Select order (' S_ Gongzi desc '), $Select-Group (' S_sheng '); Group//$Select (' Maximum wage >10000 '); Additional condition $select, order (' Maximum wage desc '); Sort $select, limit (0,0); Interception $select-Limitpage ($page, $B); Paging/*sql statement equivalent: Select S_sheng as Province, SuM (S_gongzi) as maximum wage from Sanguo Group by S_sheng have the highest wage >10000 order by highest wage desc limit 0,10;*/$Result = $Db->fe Tchall ($Select); echo " "; Echo" "; foreach ($Result as $key = + $value) {echo" "; foreach ($value as $key 2 = + $value 2) {echo " "; } echo " ";} echo " "; Echo" "; Echo" "; Echo"
Provinces Total Wages Minimum wage Maximum wage Average wage
" . $value 2. "
"Echo" Home ", if ($page >1) {echo" Prev ";} for ($i =1; $i <=15; $i + +) {echo "". $i. " ";} if ($page < $Total) {echo "next page";} echo "Last"; echo "
";? >

http://www.bkjia.com/PHPjc/741815.html www.bkjia.com true http://www.bkjia.com/PHPjc/741815.html techarticle This article mainly introduces the ZF Framework DB class pagination example, the code is very simple, you can take a look at the comments to use the ZF framework of the page sample code is as follows:? Phpisset ($_get[' page ")? $pa ...

  • Related Article

    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.