Part of the EllisLab Network

Bug Report

Active Record Object Notation Broken - $this

Date: 08/09/2007 Severity: Minor
Status: Resolved Reporter: slynn1324
Version: 1.5.4
Keywords:
Forum Thread: http://codeigniter.com/forums/viewthread/46694/

Description

the code sample listed in the user guide will not function correctly, due to the existence of ‘_parent_name’ ,’_ci_scaffolding’ , and ‘_ci_scaff_table’ being inherited from the parent Model object.  A fix to remove these variables in the _object_to_array($object) function under the DB_active_rec class fixes this problem.

Code Sample

class Blogmodel extends Model {

    
var $title   = '';
    var
$content = '';
    var
$date    = '';

    function
Blogmodel()
    
{
        
// Call the Model constructor
        
parent::Model();
    
}
    
    
function get_last_ten_entries()
    
{
        $query
= $this->db->get('entries', 10);
        return
$query->result();
    
}

    
function insert_entry()
    
{
        $this
->title   = $_POST['title'];
        
$this->content = $_POST['content'];
        
$this->date    = time();

        
$this->db->insert('entries', $this);
    
}

    
function update_entry()
    
{
        $this
->title   = $_POST['title'];
        
$this->content = $_POST['content'];
        
$this->date    = time();

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

}

Expected Result

a proper call to insert_entry() should insert into the database

Actual Result

error, no fields in database named ‘_parent_name’ ,’_ci_scaffolding’ , and ‘_ci_scaff_table’

Comment on Bug Report

Page 1 of 1 pages
Posted by: wouaren on 22 November 2007 6:28am
wouaren's avatar

This is annoying !

Posted by: Archiloque on 14 February 2008 2:32pm
no avatar

I have the same problem with other fields :
_ci_ob_level _ci_view_path _ci_is_php5 and _ci_is_instance

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?