示例#1
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new producthome();
         $o->where("productcat_id", $this->productcat_id);
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
         $o->clear();
         $o = new producthome();
         $o->where('productcat_id', $this->productcat_id);
         $o->where('product_id', $this->product_id);
         $o->get();
         if ($o->exists()) {
             return true;
         }
     }
     return parent::save($object, $related_field);
 }