After further thoughts however... I realized it's a bit semantically incorrect to do in this way...
Maybe I'm too strict about that but it's a bit nonsense - let's say in my point of view - to create a new datamapper model instance and then calling a method on an empty object as model should be more considered as definition or factories, not "record containers"... a bit like the default ci models declaration finally:
But to achieve doing that, we should also modify the main Datamapper code and add some more methods on the CI Loader class (it should be not really difficult by the way).
Along these lines, get some records could be coded like this:
$this->datamapper->load('datamodel');
$this->datamodel->where('name !=', 'Bill');
$records = $this->datamodel->get(); // $records is an array containing new datamodel records
foreach ($records as $record)
{
...
}
Code:
$this->datamapper->load('datamodel');
$record = $this->datamodel->new_record(); // more like in the ignited record way
$record->{field}='newvalue';
$record->save(); // insert
Code:
$this->datamapper->load('datamodel');
$record = $this->datamodel->get_by('id >', 4); // $record contains new datas
$record->{field}='newvalue';
$record->destroy(); // record deleted and resets to a new empty record
Code:
$this->datamapper->load('datamodel');
$this->datamodel->where('id >', 4);
$this->datamodel->delete(); // delete records that satisfy the where condition
OK... Notice that the goal of this comment wasn't of course to criticize your excellent work and contribution ;-)... but I feel it would be more correct to do in this way - I know, maybe it's a bit strange...
What do you think about this way to code ? Don't hesitate to be honest ... If you think it's a really stupid way, just say it... I'm trying to improve myself ;-).