Welcome Guest, Not a member yet? Register   Sign In
really simple...cannot get update query working
#1

[eluser]alectrash[/eluser]
In my controller I have this code:

Code:
//create array of query data
$updatedata = array('dbblogauthor' => $this->input->post('author'), 'dbblogdate' => $this->input->post('date'), 'dbblogtitle' => $this->input->post('title'), 'dbblogtag1' => $this->input->post('tag1'), 'dbblogtag2' => $this->input->post('tag2'), 'dbblogtag3' => $this->input->post('tag3'), 'dbblogcontent' => $this->input->post('content'));
$this->blog_model->edit_entry($data['blogid'], $updatedata);

and in my model I have this code:

Code:
//updates an entry in blog table
function edit_entry($blogid, $updatedata)
{
   //query
   $this->db->where('dbblogid', $blogid)->update('tblblog', $updatedata);
}

it just doesn't appear to be working and i am now stuck for ideas
#2

[eluser]nevsie[/eluser]
i normally use active record to do this and make my life easier? So different from your method, but worth giving it a try?

http://ellislab.com/codeigniter/user-gui...tml#update

Code:
$data = array(
               'title' => $title,
               'name' => $name,
               'date' => $date
            );

$this->db->where('id', $id);
$this->db->update('mytable', $data);

// Produces:
// UPDATE mytable
// SET title = '{$title}', name = '{$name}', date = '{$date}'
// WHERE id = $id
#3

[eluser]alectrash[/eluser]
I took the code out of my model and back in the controller and in worked.

Thankyou




Theme © iAndrew 2016 - Forum software by © MyBB