Home  >  Article  >  Backend Development  >  smartprinter virtual printer smarty+adodb+php development mode of some custom classes

smartprinter virtual printer smarty+adodb+php development mode of some custom classes

WBOY
WBOYOriginal
2016-07-29 08:35:571135browse

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 the 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}&c
$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 the construction In addition to 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 as classes and placed in the class, but it seems a bit bloated and contrived) .
But in terms of convenience, if a piece of code or a function is not called elsewhere, you can put mc together and keep v alone. This requires careful analysis of the software.

The above introduces the PHP development model of smartprinter virtual printer smarty+adodb+ some custom classes, including the content of smartprinter virtual printer. I hope it will be helpful to friends who are interested in PHP tutorials.

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