Smarty + adodb + php development mode for some custom classes

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.