Devam Ediyor

518937 MYSQL Trigger

I have a field in my database that occassionally gets populated with the following string:

O:8:"mgm_post":8:{s:11:"purchasable";s:1:"N";s:13:"purchase_cost";s:1:"0";s:15:"purchase_expiry";s:0:"";s:17:"purchase_duration";s:1:"0";s:7:"product";a:0:{}s:23:"access_membership_types";a:0:{}s:12:"access_delay";a:0:{}s:15:"access_duration";s:1:"0";}

I need to switch this string to a similar but altogether different string, this one:

O:8:"mgm_post":8:{s:11:"purchasable";s:1:"N";s:13:"purchase_cost";s:1:"4";s:15:"purchase_expiry";s:0:"";s:17:"purchase_duration";s:1:"0";s:7:"product";a:0:{}s:23:"access_membership_types";a:1:{i:0;s:6:"member";}s:12:"access_delay";a:4:{s:5:"guest";s:1:"0";s:5:"trial";s:1:"0";s:4:"free";s:1:"0";s:6:"member";s:1:"0";}s:15:"access_duration";s:1:"0";}

I dont claim to be very good at SQL but this is what i have come up with:

CREATE TRIGGER setMetaValue BEFORE INSERT ON wp_postmeta

FOR EACH ROW

BEGIN

IF NEW.meta_value = 'O:8:"mgm_post":8:{s:11:"purchasable";s:1:"N";s:13:"purchase_cost";s:1:"0";s:15:"purchase_expiry";s:0:"";s:17:"purchase_duration";s:1:"0";s:7:"product";a:0:{}s:23:"access_membership_types";a:0:{}s:12:"access_delay";a:0:{}s:15:"access_duration";s:1:"0";}' THEN

SET NEW.meta_value = 'O:8:"mgm_post":8:{s:11:"purchasable";s:1:"N";s:13:"purchase_cost";s:1:"4";s:15:"purchase_expiry";s:0:"";s:17:"purchase_duration";s:1:"0";s:7:"product";a:0:{}s:23:"access_membership_types";a:1:{i:0;s:6:"member";}s:12:"access_delay";a:4:{s:5:"guest";s:1:"0";s:5:"trial";s:1:"0";s:4:"free";s:1:"0";s:6:"member";s:1:"0";}s:15:"access_duration";s:1:"0";}';

END IF;

END $$

DELIMITER ;

However i get error warnings of syntax errors, could this be because of the characters in the string?

If this is true (even if its not) Can anyone help with a fix?

Regards

Beceriler: Her şey Kabul, MySQL

Daha fazlasını görün: mysql free, free mysql, mysql characters, mysql member, sql syntax error, mysql sql syntax, create mysql product database, mysql product database, sql syntax, fix sql errors, switch fix, mysql database trigger, insert mysql, sql trial, mysql database errors, fix error free, mysql row, trigger mysql, trigger sql database, insert string, need trigger database, create free mysql database, sql trigger, sql true, database insert field

İşveren Hakkında:
( 2 değerlendirme )

Proje NO: #2264871

Seçilen:

eperfections

Hi, I am excellent database and Sql programmer. I can fix your trigger issue. Please accept bid. Thanks

0 gün içinde 30$ USD
(366 Değerlendirme)
7.1