1. the table () function thinkphp provides a table () function. for specific usage, see the following statements: $ list $ Demo-& gt; table (& amp; #39; think_blogblog, think_typetype & amp; #39;)-& gt ;...
1. table () function
A table () function is provided in thinkphp. for specific usage, refer to the following statements:
- $ List = $ Demo-> table ('think _ blog, think_type type')-> where ("blog. typeid = type. id and blog. id = '$ ID' ")-> field ('Blog. id as id, blog. title, blog. content, type. typename as type ')-> order ('Blog. id desc ')-> limit (5)-> select ();
- Echo $ Demo-> getLastSql (); // Print the SQL statement and check it
2. join () function,Take a look at the code:
- $ Demo = M ('artlist ');
- $ Demo-> join ('right JOIN think_work ON think_artist.id = think_work.artist_id ');
- // You can use inner join or left join. Note the table name prefix!
- Echo $ Demo-> getLastSql (); // Print the SQL statement and check it
3. native query
- $ Model = new Model ();
- $ SQL = 'SELECT. id,. title, B. content from think_test1 as a, think_test2 as B where. id = B. ID '. $ map. 'order by. ID '. $ sort. 'limit '. $ p-> firstRow. ','. $ p-> listRows;
- $ VoList = $ Model-> query ($ SQL );