[eluser]alaminx[/eluser]
hi all!
I've just start in Datamapper.
you know, the save method use to save new object or update exists object. I want to insert the position properties if it is new object
Code:
function save()
{
//check new object or exists object
if(empty($this->id))
{
$ci =& get_instance();
$ci->firephp->log('Change position status');
$o = new Country();
$o->select_max('position');
$o->get();
if(count($o->all)!=0)
{
$max=$o->position+1;
$this->position=$max;
}
else
{
$this->postion = 1;
}
}
return parent::save();
}
How do I check current object is new or exist??