thinkphp PHP Framework Learning notes _php Tips

Source: Internet
Author: User
It took two more minutes to see thinkphpFramework, do not want to be too deeply aware of its all the advanced theory. Simply want to know how can use up, can quickly build a website. So there is a choice to see, after two minutes or confused. So decided to change the learning strategy, on the official forum to see other people write folk tutorials, it is more easily understandable than the official.http://bbs.thinkphp.cn/forumdisplay.php?fid=6(Official forum)

thinkphpThere are a lot of functions that can be combined by a piece of argumentSqlAs follows:$list = $test->findall (', $fields, ' id desc ', $p->firstrow. ', '. $p->listrows);Although such a patchwork approach simplifies ourSqlStatement, but this also requires us to remember a lot of function methods, I do not want to remember too much such things, feel that sometimes it is better to write a completeSqlEasy to come by. Don't knowthinkphpIs there any direct writingSqlAfter executionSelectThe function method of the query? Later learnedModel.class.phpThere's a way inside.Public Function query ($sql)Can meet the requirements I want! When you do pagination, you useQueryMethod skips the use of the FindAllmethod to implement the paging function.

See examples and tutorials are on a single table operation, but in many cases we need to use multiple table joint operations. What should we do at this time, such as a multiple table joint query? thinkphp has considered this problem, and has been very thoughtful to help us arrange the associated query and associated operations. I don't have much trouble with this! In fact, the flexible use of the framework of some of the basic function methods, you can reach the associated query and associated operations. There's no need to remember a whole bunch of crap.

Data paging is often used in a function, TP this aspect to do quite simple. Find a tutorial on the Internet ( http://bbs.phpchina.com/thread-52813-1-1.html ), I thought that reference to this tutorial to write a TP paging program should be very simple. I didn't think it was quite a struggle!

① First encountered Fatal error: Class ' don't found in .... the error prompted a generalist on the internet to know is missing an extended class library. Later downloaded the corresponding file on the official website.

②     Extended Class Library There is no hint of error, but still can not correctly show the desired results! View page Trace information , originally SQL have problems SELECT COUNT () as Tp_count from ' Think_demo ' LIMIT 1 , the analysis concludes this sentence of the $count =  $test->count (', ' id ') the code has a problem, changed to $count  =  $test->count (' ID ') finally saw the hyperlink to the next page of the previous page. Do not book as much as you believe!

③     Tutorial $list  =  $test->findall (', $fields, ' Id desc ', $p->firstrow. ', '. $p-> ListRows); This code doesn't get the results I want, and I don't want to go into the details of how the various parameters of the FindAll method are used. It is then changed to $list = $test->query ("Select $fields think_demo ORDER BY id desc limit $p->firstrow, $p->listrows" ) . Run again, this time finally put the paging out!

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.