Home  >  Article  >  Backend Development  >  Sharing of paging examples of zf framework db class_PHP tutorial

Sharing of paging examples of zf framework db class_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:35:591459browse

This article mainly introduces the paging example of the zf framework db class. The code is very simple. You can use it just by reading the comments

Pagination example of zf framework ​ The code is as follows: '127.0.0.1' , 'username' => 'root' , 'password' => '111' , 'dbname' => 'test', 'profiler' => "true" ); //Tell the Zend_Db class the database and database configuration information operated by $Db = Zend_Db::factory('PDO_Mysql' , $Config); //Execute encoding statement $Db -> query("set names utf8"); //-------------------------------------------------- //Use the fetchOne() method to get the total number of entries in the table $Total = $Db -> fetchOne("select count(*) from gongsi"); //Define the number of items displayed on each page $B = 50; //Get the total number of pages $A = ceil($Total/$B); ​ //-----The next step is a series of operations such as query tables, result sets, paging, etc. $Select = $Db ->select(); $Select -> from('sanguo',array('s_sheng as province','sum(s_gongzi) as total salary','min(s_gongzi) as minimum salary','max(s_gongzi) as maximum salary',' avg(s_gongzi) as average salary')); // $Select -> Where('s_gongzi>=3000'); // $Select -> Where("s_sheng='Hebei'"); // $Select -> order('s_sheng asc'); // $Select -> order('s_gongzi desc'); $Select -> group('s_sheng'); //Group //$Select -> having('Maximum salary>10000'); //Additional conditions $Select -> order('Highest salary desc'); //Sort $Select -> limit(0,0); //Interception $Select -> limitPage($page, $B); //Paging /*SQL statement is equivalent to: select s_sheng as province,sum(s_gongzi) as maximum salary from sanguo group by s_sheng having maximum salary>10000 order by maximum salary desc limit 0,10; */ $Result = $Db->fetchAll($Select); ​ echo ""; echo "< ;th>Average salary"; foreach ($Result as $key => $value) { echo ""; foreach ($value as $key2 => $value2) { echo ""; } echo ""; } echo ""; echo ""; echo ""; echo "
ProvinceTotal salaryMinimum salaryMaximum salary
" . $value2 . "
"; 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 "
"; ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/741815.htmlTechArticleThis article mainly introduces the paging example of the zf framework db class. The code is very simple. Just look at the comments. The paging example code using the zf framework is as follows:?phpisset($_GET['page']) ? $pa...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn