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

[eluser]Wonder Woman[/eluser]
Hi,

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.
#2

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

[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.
#4

[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)
#5

[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-/
#6

[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

Code:
$this->db->select('id');
$this->db->limit($limit,$offset);
$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