Home > Backend Development > PHP Tutorial > PHP development mode of smarty+adodb+some custom classes_PHP tutorial

PHP development mode of smarty+adodb+some custom classes_PHP tutorial

WBOY
Release: 2016-07-21 15:58:42
Original
821 people have browsed it

A few days ago, I basically finished the backend of HotNet, and I took some time to summarize the work.
In terms of design mode, I tried to use the mvc mode of development. Use smarty to control the display, use case statements to control various actions, and then write classes of various modules for action calls. This does provide better control over the code. For example, if you write the getAllMsg() function in class.message.php, then this function can be called by many actions. Then add the paging class. It is quite flexible in data processing.

Copy code The code is as follows:
$db=new Db;
$sql="select * from com_info,hr_info where hr_info .ci_id=com_info.id and {$cate} like '%{$content}%'";
$totalArr=$db->execute($sql);
$url="hr.php? op=searchHrInfoAction&cate={$cate}&content=".urlencode($content);
$totalItems=count($totalArr);
$currentPageNumber=(isset($_GET['page']))?$ _GET['page']:1;
$pageNav=new PageNumber($currentPageNumber,$totalItems,3,3,$url);
$currentPageRs=$pageNav->getRsPerPage(&$totalArr);
$pageNavigation=$pageNav->getPageNumber();
$smarty->assign("pageNavigation",$pageNavigation);
$smarty->assign("hr",$currentPageRs) ;
$smarty->display("hr_get.htm");
And this method is very helpful for collaborative development, and the code duplication rate is not very high.
But as shown in the above code, in addition to constructing the classes of various modules, due to the existence of various personalized queries, it is inevitable to use the db class directly in the control (of course, these processes can also be written in classes in class, but seems a bit bloated and contrived).
But in terms of convenience, if a piece of code or a function is not called from other places, you can put mc together and keep v alone. This requires careful analysis of the software. After get off work, go home.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317517.htmlTechArticleI basically completed the backend of Hotnet a few days ago, and I took the time to summarize the work. In terms of design mode, I tried to use the mvc mode of development. Use smarty to control the display and case statements to control...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template