Welcome Guest, Not a member yet? Register   Sign In
Replace old data to new data by Group ID
#1

I have table like


Code:
tb_class
---------------------------------------------------------
id | group_id | name | class | hour
---------------------------------------------------------
1 | 1 | aaaaa | xi | 20
2 | 1 | bbbb | xx | 30
3 | 1 | ccccc | xq | 40
4 | 2 | dddd | zy | 10


And i implement sortable for draggable to replace old records tb_class by group_id.

Code:
tb_class
---------------------------------------------------------
id | group_id | name | class | hour
---------------------------------------------------------
4 | 2 | dddd | zy | 10
5 | 1 | eeee | qe | 60
6 | 1 | fffffff | qw | 32
7 | 1 | gggg | qq | 26
8 | 1 | hhhh | qr | 53

Can i use replace() function in Model? I need sample model to provide this
Reply
#2

The "replace" method replaces the entry and applies the new ID if the entry exists. This is bad. Use the "update" method 

http://codeigniter.com/user_guide/databa...der-update
Reply




Theme © iAndrew 2016 - Forum software by © MyBB