Examples of the zf framework db class are shared by page. This article mainly introduces the paging example of the db Class of the zf framework. the code is very simple. let's take a look at the comments and use the following code as a paging example of the zf framework :? Phpisset ($ _ GET [page])? $ Pa This article mainly introduces the paging example of the zf framework db Class. the code is very simple. you can use it by taking a look at the annotations.
The following is a paging example code of the zf framework: '2017. 0.0.1 ', 'username' => 'root', 'password' => '000000', 'dbname' => 'test', 'filer' => "true "); // inform Zend_Db of the database and database configuration information operated by the Zend_Db class $ Db = Zend_Db: factory ('pdo _ mysql', $ Config ); // execute the encoding statement $ Db-> query ("set names utf8"); // ----------------------------------------------- // use fetchOne () method to get the Total number of tables $ Total = $ Db-> fetchOne ("select count (*) from gongsi"); // defines the number of entries displayed on each page $ B = 50; // obtain the Total number of pages $ A = ceil ($ Total/$ B ); // ----- perform the following operations for a series of queries, result sets, and pages: $ Select = $ Db-> select (); $ Select-> from ('sango ', array ('s _ sheng as province ', 'sum (s_gongzi) as total wage', 'min (s_gongzi) as minimum wage ', 'Max (s_gongzi) as highest wage ', 'avg (s_gongzi) as average wage '); // $ Select-> Where ('s _ gongzi> = 100 '); // $ Select-> Where ("s_sheng = 'hebei '"); // $ Select-> order ('s _ sheng asc '); // $ Select-> order ('s _ gongzi desc '); $ Select-> group ('s _ sheng '); // group // $ Select-> having ('maximum salary> 100'); // additional conditions $ Select-> order ('maximum salary desc '); // Sort $ Select-> limit (0, 0); // Intercept $ Select-> limitPage ($ page, $ B); // the page/* SQL statement is equivalent: select s_sheng as province, sum (s_gongzi) as highest salary from sanguo group by s_sheng having highest salary> 10000 order by highest salary desc limit; */$ Result = $ Db-> fetchAll ($ Select); echo"
"; Echo"
Province |
Total salary |
Minimum wage |
Highest salary |
Average salary |
"; Foreach ($ Result as $ key => $ value) {echo"
"; Foreach ($ value as $ key2 => $ value2) {echo"
". $ Value2 ." | ";} Echo"
";} Echo"
"; Echo"
"; Echo" homepage "; if ($ page> 1) {echo" previous page ";} for ($ I = 1; $ I <= 15; $ I ++) {echo "". $ I. "";} if ($ page <$ Total) {echo "next page";} echo "last page"; echo" | "; Echo"
"; Echo"
";?>
The following is a paging example code of the zf framework :? Phpisset ($ _ GET ['Page'])? $ Pa...