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"
Provinces |
Total Wages |
Minimum wage |
Maximum wage |
Average wage |
"; foreach ($Result as $key = + $value) {echo"
"; foreach ($value as $key 2 = + $value 2) {echo "
" . $value 2. " | "; } echo "
";} echo "
"; Echo"
"Echo" Home ", if ($page >1) {echo" Prev ";} for ($i =1; $i <=15; $i + +) {echo "". $i. " ";} if ($page < $Total) {echo "next page";} echo "Last"; echo " | "; Echo"
"; 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 ...