Welcome Guest, Not a member yet? Register   Sign In
Error 1054
#2

[eluser]gtech[/eluser]
[url="http://ellislab.com/forums/viewthread/46694/"]http://ellislab.com/forums/viewthread/46694/[/url]

The problem with the models userguide section is that it suggests to pass $this to the update, however when you pass this you are also passing _ci_scaffolding to the insert, as extending from model includes these values for scaffoliding.

so do not pass $this to any active record functions, it is bad practice

documentation example
Code:
function update_entry()
{
    // yuck yuck as this->_ci_scaffolding will exist and try to insert/update
    // it into the database as a column name.
    $this->title   = $_POST['title'];
    $this->content = $_POST['content'];
    $this->date    = time();

    $this->db->update('entries', $this, array('id', $_POST['id']));
}


SO instead of doing the above you can do
Code:
function update_entry()
{
    $data = array(
               'title' => $_POST['title'],
               'content' => $_POST['content'],
             );

    $this->db->where('id', $_POST['id']);
    $this->db->update('entries', $data);
}


Messages In This Thread
Error 1054 - by El Forum - 06-09-2008, 11:12 AM
Error 1054 - by El Forum - 06-09-2008, 04:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB