Home >Backend Development >PHP Tutorial >Some summary of php connecting to database
In PHP project development, the MVC framework is generally used for development, and the interaction with the database is generally carried out in the model. The following is a brief introduction to some PHP processing when interacting with the database:
1. Direct processing:
$this->load->database('database name') ;
$query = $this->db->get('table name');
echo $row->name; }
=
new
$stmt = $this-> conn
->prepare( $sql ); $stmt
->execute($data
);$res = $stmt ->fetch ();In actual development, we will write our own interface form for accessing the database based on the above method to complete more convenient functions. If you have any additions or corrections, please reply and communicate.
The above introduces some summary of PHP connection to the database, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.