Exemplo n.º 1
0
 public function save_group($data)
 {
     if (!empty($data['id'])) {
         CI::db()->where('id', $data['id'])->update('customer_groups', $data);
         return $data['id'];
     } else {
         CI::db()->insert('customer_groups', $data);
         $groupId = CI::db()->insert_id();
         //create the new fields.
         CI::load()->dbforge();
         $fields = ['enabled_' . $groupId => ['type' => 'TINYINT', 'constraint' => '1', 'default' => '1'], 'price_' . $groupId => ['type' => 'DECIMAL', 'constraint' => '10,2', 'default' => '0.00'], 'saleprice_' . $groupId => ['type' => 'DECIMAL', 'constraint' => '10,2', 'default' => '0.00']];
         CI::dbforge()->add_column('products', $fields);
         CI::dbforge()->add_column('order_items', $fields);
         $fields = ['enabled_' . $groupId => ['type' => 'TINYINT', 'constraint' => '1', 'default' => '1']];
         CI::dbforge()->add_column('categories', $fields);
     }
 }