This article mainly introduces ThinkPHP's method of using native query to implement join query leftjoin. The example shows how to use the query method in ThinkPHP. For more information, see
This article mainly introduces ThinkPHP's method of using native query to implement join query left join. The example shows how to use the query method in ThinkPHP. For more information, see
This example describes how ThinkPHP uses native javascript/2013122363709.html "> query to implement join query left join. Share it with you for your reference. The details are as follows:
Thinkphp provides the join method to implement join queries, but it is not easy to use. It is still convenient to use native. Therefore, we recommend that you use the query method:
The Code is as follows:
$ Model = new Model ();
$ SQL = "SELECT a. id, a. attr_name, a. attr_input_type, a. attr_type, a. attr_values, v. attr_value, v. attr_price ".
"FROM hh_typeattr AS ".
"Left join hh_siteattr AS v ".
"ON v. attr_id = a. id AND v. site_id = '$ site_id '".
"WHERE a. type_id =". intval ($ type_id). "OR a. type_id = 0 ".
"Order by a. listorder, a. attr_type, a. id, v. attr_price, v. id ";
$ Row = $ Model-> query ($ SQL );
I hope this article will help you with ThinkPHP framework programming.
,