A few days ago, I basically finished the hot Network Background and made time to summarize the work.
In terms of the design pattern, I tried to use the mvc pattern for development. Use smarty to control the display, use case statements to control various actions, and write classes of various modules to call actions. In this way, the code is better controlled. For example, if you write the getAllMsg () function in class. message. php, this function can be called by many actions. With the paging class. Data processing is flexible.
Copy codeThe 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 ");
In addition, this method is very helpful for collaborative development, and the code repetition rate is not very high.
However, as shown in the code above, in addition to constructing classes of various modules, because of the existence of various personalized queries, it is inevitable that db classes will be directly used in control (of course, these processes can also be written into classes, but they are a little bloated and pretentious ).
However, for convenience, if a piece of code or a function is not called elsewhere, you can put mc together and save v separately. This requires careful analysis of the software. After work, go home to the building.