The MY_Model save method is a part of the MY_Model library, which is a lightweight wrapper for the CodeIgniter framework used for building applications. The save method is used to manipulate database tables and store data in them.
Example 1:
//Create an instance of MY_Model $this->load->model('MY_Model'); $my_model = new MY_Model(); $data = array( 'name' => 'John Doe', 'email' => 'johndoe@example.com', 'phone' => '1234567890' ); $result = $my_model->save('mytable', $data);
In this example, we first create an instance of the MY_Model class using the CodeIgniter's load model function. We then create an array of data containing values for the 'name', 'email', and 'phone' fields of the 'mytable' table. Finally, we call the save function of the MY_Model object, passing the table name and data array as parameters.
Example 2:
//Create an instance of MY_Model $this->load->model('MY_Model'); $my_model = new MY_Model();
//Update record where id is 1 $data = array('email' => 'janedoe@example.com'); $result = $my_model->save('mytable', $data, 1);
In this example, we first create an instance of the MY_Model class using the CodeIgniter's load model function. We then create an array of data containing the updated 'email' field value for the record with id 1. Finally, we call the save function of the MY_Model object, passing the table name, data array, and the record id as parameters.
The MY_Model library belongs to the CodeIgniter PHP package library.
PHP MY_Model::save - 30 examples found. These are the top rated real world PHP examples of MY_Model::save extracted from open source projects. You can rate examples to help us improve the quality of examples.