MyBB Community Forums

Full Version: Update Query
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Basically, I want to update one row inside my database but the code I am using seems to update all the rows.

$db->update_query("tickets", array("resolved" => "y"));

Is there a way to target the one row? I have a fid field which determines different tickets, e.g. 1 is support etc..
I have another field, by, which determines who submitted the ticket
I have another field, resolved, which determines if the ticket has been resolved or not
I have a last field, info, which stores the ticket message.

Should I make a uid field and target the uid of the ticket that I want to change to resolved?

How would I go about targetting the uid?

Thanks in advance

EDIT: So if the UID was 1, then i want to update the resolved field to y ONLY where the uid is 1 instead of updating all the rows.
you should make a ticket id (with unique value) and target that (update where ticket id = x)
(09-21-2015, 05:40 PM).m. Wrote: [ -> ]you should make a ticket id (with unique value) and target that (update where ticket id = x)

I thought so, could you tell me how i could target it? like a sample code using the id as 1? It would be much appreciated

Edit: Like this? $db->update_query("tickets", array("resolved" => "y"), WHERE "id == '2'");

[Image: 13c8e5226cb999657dd29c2708358bf2.png]

If i wanted to update the resolved field for the id 2 to 'y', how would i do this?

the closest bet i have is: $db->update_query("tickets", array("resolved" => "y"), WHERE "id == '2'");
@Nineteh you can try with this:

$db->update_query("tickets", array("resolved" => "y"), "id=2");