Thanks, but the _parent_name is in the Model base class. See source code libraries, Model.
I dont want to insert a column in my db-tabel just for this _parent_name expecially
if I dont see any reason for..
It should be a possibility to exclude it.
// We don't want to assign the model object to itself when using the // assign_libraries function below so we'll grab the name of the model parent $this->_parent_name = ucfirst(get_class($this));
oh, now I see, that Ruud reedited his post.
But it would be nicer, if we could use the $this for updating.
In CI Docs ->Model there is an example with the insert like this
would work in previous versions, but since “_parent_name” appeared in 1.5 it’s no longer valid.
It is possible, however, to modify “CI_DB_active_record::_object_to_array” method to check for “_parent_name” variable and simply not assign it to the returned array.
Rewrite the function _object_to_array($object beginning on line 830 of DB_active_rec.php in the system/database folder to the following. This will allow the code written in the usage guide to work correctly, eg.
$this->db->insert('stories', $this);
If anybody sees any side effects to this change, let me know. Otherwise, can this be submitted to the baseline code?
/** * Object to Array * * Takes an object as input and converts the class variables to array key/vals * * @access public * @param object * @return array */ function _object_to_array($object) { if ( ! is_object($object)) { return $object; }
Ok to verify that the fix is not in 1.6.2, I have to modify system/database/DB_active_rec.php in the _object_to_array method to get my app to work as per the “Models” documentation on the codeigniter userguide. I had to change the if statement code to look like this
// There are some built in keys we need to ignore for this conversion
This thread is kind of old and rambling, so I’m not sure what you are referring to. I think you mean inserting via an object? Could you provide some code?