The php framework does not need to write SQL statements to call the fields of tables in the database. it is said that many frameworks do not need to write SQL statements and can call the fields of data tables only by encapsulation, this is how it is implemented. it is incredible because the traditional tutorials all say that the database cannot be operated without SQL statements. what is the problem?
Reject posts that Post articles in Baidu. Have your own opinions
Reply to discussion (solution)
This is a good implementation
Write a php class to write database operation statements to this class.
And then pass the parameter call. I do not know if it is white.
Each function in the class represents different operations.
Encapsulate the most basic operations into classes and then call OOP directly.
Encapsulate the most basic operations into classes and then call OOP directly.
Can you give me an example? for example, how can I encapsulate the select database query statement? just write it down. I don't want to know the details. I just want to know about it!
Most php frameworks simulate the implementation of ORM (object relationship Ing, a conceptual and easy-to-understand method for modeling data) to a certain extent, but it is eventually translated into SQL instructions for execution.
Most php frameworks simulate the implementation of ORM (object relationship Ing, a conceptual and easy-to-understand method for modeling data) to a certain extent, but it is eventually translated into SQL instructions for execution.
In this case, do I still rely on SQL statements to execute commands? Can you write a translation sentence? it's easy, just a little bit.
Of course, the methods in the framework are encapsulated. In the final analysis, it is also necessary to execute SQL.
function select($table,$field_array){ $field = implode(',', $field_array); $r = mysql_query("select $field from $table"); return $r;}
The above is a simple example. the perfect writing method should be written as a class. you can find an example on the Internet.
The example above is pretty nice.