id)) { $this->module_id = $mid; // We'll get the next ID as the MAX(id) of the table $mo = ORM::factory('Module',$mid); $max = DB::select(array('MAX(id)','id')) ->from($mo->name) ->where('site_id','=',Company::instance()->site()); $this->id = $max->execute()->get('id'); } $this->id++; if (! $this->save()) throw new Koahan_Exception(_('Unable to increase ID for :table'),array(':table'=>$mid)); return $this->id; } } ?>