Welcome Guest, Not a member yet? Register   Sign In
CRUD and multiple updating

[eluser]Wonder Woman[/eluser]

I am wanting to create a CRUD admin section and I have the basic elements already set up - although I want to be able to set records so for example you could set a stored member's account as active or inactive by using a checkbox and doing a multiple update. Is this possible? If so, could you point me in the right direction, thanks.

[eluser]Cristian Gilè[/eluser]
Wonder Woman, it sounds like your prevoius post (http://ellislab.com/forums/viewthread/176677/). I can't see much difference.

[eluser]Wonder Woman[/eluser]
Hey Cristian Gilè,

That's because it is in a way, I realised that I need to be able to update all of the entries where the checkbox has returned false so if the entry is true then set the database to 1 if empty set the entry to 0. Any ideas? Thanks.

[eluser]Cristian Gilè[/eluser]
I hope I understood what you mean. Here my solution.

After submit the form follow these steps:

1. update your table and set to 0 all the entries
2. update your table and set to 1 only the entries you have in the post var (the checkbox array)

[eluser]Wonder Woman[/eluser]
That's what I thought but I'm paginating my results so I can't do that because I will be setting all of the other results to 0 on the other pages. 8-/

[eluser]Cristian Gilè[/eluser]
If you use pagination you can pass to the model limit and offset and select IDs of the entries you need to update

$query = $this->db->get('your_table');

Now, with the IDs list, you can use the above approach to update the entries.

Theme © iAndrew 2016 - Forum software by © MyBB