Simple use of select queryer for Db in ZF Framework & pagination
Simple use of select lookup in ZF framework Db & pagination
'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 wage minimum wage highest wage average wage "; 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
The above is the simple usage and paging content of the select queryer of the ZF framework Db Class. For more information, see The PHP Chinese network (www.php1.cn )!