I have no idea if this is even remotely correct. I have a class where I would like to update the database if the fields currently exist, or insert if they do not exist. The difficulty is that I am doing a join of 3 tables (set_colors, school_art, baseimage)
Any help would be very helpful.
Here is what I have:
public function set_layer_colors($value) { global $db; $result_array = mysql_query(" IF EXISTS(SELECT * FROM set_colors WHERE school_art_id = '{$value}') UPDATE set_colors (school_art_id, baseimage_id, sub_folder, layer) SELECT school_art.id, baseimage.id, baseimage.sub_folder, baseimage.layer FROM school_art JOIN baseimage ON baseimage.base_folder = school_art.series_code WHERE baseimage.image_type = 'B' ORDER BY school_art.id ELSE INSERT INTO set_colors (school_art_id, baseimage_id, sub_folder, layer) SELECT school_art.id, baseimage.id, baseimage.sub_folder, baseimage.layer FROM school_art JOIN baseimage ON baseimage.base_folder = school_art.series_code WHERE baseimage.image_type = 'B' ORDER BY school_art.id "); return $result_array; }
php mysql
GGcupie Jul 28 '11 at 1:27 2011-07-28 01:27
source share