forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 upload => Topic started by: buddy0815 on March 19, 2011, 07:02:13 pm

Title: update another table when uploading a picture
Post by: buddy0815 on March 19, 2011, 07:02:13 pm
Hi guys,

I would like to implement a little modification in cpg. Everytime the cpg15x_pictures table is changing (e.g. when uploading a new pictures) I would like to update another table in the same database. The coding shouldn't be the problem. But I need help to find the right places in the php files.

Where do I have to place my table update lines. In the upload.php and update.php? If so, where exactly in those files?

Thanks in advance

Regards
Title: Re: update another table when uploading a picture
Post by: Nibbler on March 19, 2011, 07:18:11 pm
Best way would be to make a plugin using the add_file_data_success (http://documentation.coppermine-gallery.net/en/dev_plugin_hooks.htm#plugin_hooks_filename_add_file_data_success) action. You could also use a database trigger. If you must edit the code directly then it's include/picmgmt.inc.php, add_picture function.
Title: Re: update another table when uploading a picture
Post by: buddy0815 on March 19, 2011, 08:05:38 pm
thanks a lot. this leeds me to some further questions

1. is the add_picture function in include/picmgmt.inc.php just executed when adding a file or is it also executed when you change attributes from an existing image?
2. do you have a how-to link where I can see how to make a plugin with the add-file_data_success action?
3. where can I found more infos about the database trigger?

Thanks in advance!

Regards
Title: Re: update another table when uploading a picture
Post by: Nibbler on March 19, 2011, 08:08:51 pm
1. New files only.
2. We don't have tutorials for all possible actions. Plugin docs are at http://documentation.coppermine-gallery.net/en/dev_plugins.htm
3. http://dev.mysql.com/doc/refman/5.1/en/triggers.html
Title: Re: update another table when uploading a picture
Post by: buddy0815 on March 19, 2011, 09:26:49 pm
thanks for your quick answer. I read the provided link about the trigger and it sounds fascinating!!! haven't heard that before. I will try that and report my experience after that.. thanks a lot! sounds to be exactly what I was locking for.