Welcome Guest, Not a member yet? Register   Sign In
Active Record Return Result Object on Insert/Update?
#1

[eluser]kmanlove[/eluser]
It seems like there should be something like this on the forum, but I was unable to find it. Forgive me if you just end up forwarding me to a post.

I want insert and update to return a result object with what was just inserted, and it really seems like it should.

In ./system/database/DB_active_rec.php, I see
Code:
function insert($table = '', $set = NULL)
    {    
        if ( ! is_null($set))
        {
            $this->set($set);
        }
    
        if (count($this->ar_set) == 0)
        {
            if ($this->db_debug)
            {
                return $this->display_error('db_must_use_set');
            }
            return FALSE;
        }

        if ($table == '')
        {
            if ( ! isset($this->ar_from[0]))
            {
                if ($this->db_debug)
                {
                    return $this->display_error('db_must_set_table');
                }
                return FALSE;
            }
            
            $table = $this->ar_from[0];
        }

        $sql = $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
        
        $this->_reset_write();
        return $this->query($sql);        
    }

The important part being "return $this->query($sql);"

The header of query looks like this:
Code:
function query($sql, $binds = FALSE, $return_object = TRUE)

Return object is true... ?

Please help me if I'm misunderstanding, and if anyone has any implementation of this, that would be really great.

Thanks,
Keith


Messages In This Thread
Active Record Return Result Object on Insert/Update? - by El Forum - 08-26-2010, 01:22 PM
Active Record Return Result Object on Insert/Update? - by El Forum - 08-26-2010, 01:47 PM
Active Record Return Result Object on Insert/Update? - by El Forum - 08-26-2010, 01:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB