Can this function be implemented without the framework or pure PHP? There are many pages with the insert, delete, and modify function. Only one add, delete, and modify method can be used for other pages.

Source: Internet
Author: User
Can this function be implemented without the framework or pure PHP? There are many pages with the insert, delete, and modify function. there is only one add, delete, and modify method. other pages can also share this method without a framework. Is this a pure PHP function? There are many pages with the insert, delete, and modify function. Only one add, delete, and modify method can be used for other pages.
I used to write a method on a page to insert a database. The boss asked all pages to write one type, and others also used to share this insertion method to insert the database. How? Can it be implemented? The inserted data table names and fields are different. how can this problem be solved?


Reply to discussion (solution)

To write a function or class, you need to use the page to include it. you just need to pass the parameter when calling it.

Write a class.

The boss said that there must be a difference, so there is a parameter

Write a class and perform parameter passing in the method.

Write a class and perform parameter passing in the method.


How does ajax submit it to the class method of this file? For example, the file is index. php, the class is add, and the method is insert ()


Write a class and perform parameter passing in the method.


How does ajax submit it to the class method of this file? For example, the file is index. php, the class is add, and the method is insert ()

You directly go to inde. php introduces this class, and then instantiates this class when submitting the class, and then calls the method in it to write the database $ model = new add (); $ model-> insert ($ data ); $ data here is the data you pass.

Yes. The framework is also encapsulated by PHP ..

To call these methods directly at the front end, you only need to pass the corresponding parameters. you can define the specific method name.

Function insert (){
}

Function delete (){
}

Function edit (){
}

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.