This is an example of how the original sql language is implemented in the context of the whiskey school of arts and arts. They are shared for your information, as follows:
How did you get the original sql phrase from the thinkph from the p in the wrong way
$model = new model();//or $model = d(); or $model = m(); $sql = "select * from `order'; $volist = $model-> q360 query ($sql);
It's just a model that needs to be created to vehemently prove the mine pen to inherit the model method。
Note that query is a check function, execute is a add or delete function
Examples of querying and reading attribute values:
$sql = "s renaming vice-presidential activity dedicated to elect * from go down new rules to more soluble ods"; $model = m(); $result = $model->query father-to-father assessment and writing water ($sql); foreach ($resul snob as $k=> $val) {$goods id = $val
"goods id"
;}

The model of tp can support the original sql operation and provides two methods: quancy and execute. Why does the original sql have two ways of moving away from the doctor's coat
1. Different types of return
Query is used for queries, returns data sets, as does select or f million lower quindall, so you can output query query results directly in the template using volist tags
Execute is used for writing operations, and returns a record of the initial or effects of a crime
2. Reading and writing statistical needs
In order to facilitate the measurement of the reading and writing times of current data, the reading and writing operation of the database is separated (the corresponding is query and execute)

It's easy to make a bar counter-expressive sql, and we don't even need to exemplify any model, for example:
$model = new model(); / / exemplify an empty model
The following method is equivalent
$model = d();/// $model = m();//$model > query ('select * from think heager soldier where status = 1'); $model->execu milligrams of te (`update think user first-in-time setset status=1 where id= 1');
If you have an example of a model, you can still perform original sql operations without being affected, for example:
$user = d ('user'); $user->query ('self * from think user where status=1'); $user->execute (`update think user set status=1 where id=1');

In this context, we could simplify the sql statement, for example:
User->query ('self* from table where status=1'); $user->execute('update table set status=1 where id=1');
The system automatically replaces table with the name of the data table corresponding to the current model, the actual data table being determined by the model。
Usually, we use the original sql to achieve some of the more difficult operations of orm and curd, and if sql is not complex, the difference between the original sql's efficiency and the efficiency of coherent operations is minimal, and the tp's own orm is quite efficient。
More readers interested in the content of the linkphp can view the topics of this site: the thinkphp introduction, the thinkphp template operating techniques summary, the thinkphp common methods summary, the codeigniter introduction, the ci (codeigniter) framework progress curriculum, zend fundIntroduction to the ramework framework and technical summary of php templates。
It is hoped that this paper will be useful for the design of the php program based on the thinkphp framework。




