The php framework does not need to write SQL statements to call the fields of tables in the database. how can this problem be achieved?

Source: Internet
Author: User
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.

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.