Job exercise ZendFramework? Php * How to Use the queryer * isset ($ _ GET [page])? $ Page $ _ GET [page]: $ page1; introduces the Loader class (automatic loading class) require_once (ZendLoader. php); Use the Loader class to introduce a Db class Zend_Loader: loadClass (Zend_Db); Introduce the Zend_Db format
Job exercise Zend Framework? Php/* How to Use the queryer */isset ($ _ GET ['page'])? $ Page = $ _ GET ['page']: $ page = 1; // introduces the Loader class (automatic loading class) require_once ("Zend/Loader. php "); // use the Loader class to introduce a Db class Zend_Loader: loadClass (" Zend_Db "); // introduce the Zend_Db format
Job exercise Zend 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"
";?>