Jump to content

How can I change a table setting on all images within a specific category?


Recommended Posts

I have a script that the developer has stopped supporting.


The script has the ability to mark images "mature", but only single images, and one by one. The script has no ability to mark an entire category mature. Is what I want to do is perform a mysql command in phpmyadmin that tells it to auto change the setting for all images in a category to be marked as mature.


Can someone help me with what command I would use to do this?


My database name: site_database

Category table: pp_categories

How cats are identified: "catorder"

Photo table: pp_photos

How photos are identified as being in the same category: "cat"

table that I need to change: "ismature"


So I was hoping for a command that I can insert into phpmyadmin, to say all images within a certain category id, change the photos table of "ismature" to 1. From my understanding of the script, this would then mark all the photos in that album on the site as mature.


Can anybody help me with what I would need to type in?

Link to comment
Share on other sites

you would use an UPDATE query with a WHERE clause to control which rows get updated. the following is the UPDATE query syntax definition of the commonly used parts highlighted -


UPDATE [LOW_PRIORITY] [iGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]


Edited by mac_gyver
Link to comment
Share on other sites

Be aware that an UPDATE query will only change the current images. A new photo will be unmarked until you run the query again.


If you want to automatically update the flag (like you said in the original post), a quick workaround would be a trigger. But of course none of this is a replacement for an actual developer who knows what he/she is doing and can fix the application itself.




@mac_gyver, Just looking over that UPDATE syntax and something's bugging me - what case would cause someone to want to ORDER BY during an update? O_o


To use it in conjuction with LIMIT or to prevent constraint violations caused by an unordered UPDATE. There are several examples in the manual.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.