Welcome Guest, Not a member yet? Register   Sign In
How to insert corporate details into database
#12

(11-20-2020, 04:31 PM)InsiteFX Wrote: Insert creates a new database record, update will update an existing record.

Delete will delete the record, replace will delete the record then insert it.


PHP Code:
$data = [
        'title' => 'My title',
        'name'  => 'My Name',
        'date'  => 'My date'
];

$builder->replace($data);

// Executes: REPLACE INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date') 

OK, I understand that. I dont think replace is appropriate.

The only one I need to use is "update" but I cant get it to work.

I want to get the contents of $product placed into the temp_1 field of an existing record. I dont want the other fields of that record interfered with.

If there is existing content within temp_1 then I want it to be overwritten. Currently, because Im dealing with a new field temp_1 is empty.

And currently, Im entering into tbl_members, and later when Ive learnt how, I will do the same in tbl_corporate that Ive recently created.

I have this in the Controller;

PHP Code:
$lcuser $this->session->userdata('user_name');
$product $this->input->post('pro');
$this->username_model->update_product($product); 

And this in the Model;

PHP Code:
public function update_product($product)
{
$this->db->where('user_name'$lcuser);
$data = array('temp_1'=> $product);
$this->db->update('tbl_members'$data);


Everything else works except the entry into temp_1.
Reply


Messages In This Thread
RE: How to insert corporate details into database - by christaliise - 11-21-2020, 11:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB