• hi7tek

    (@hi7tek)


    Hi, one of my records within the option table is this string (option_value):

    a:4:{i:0;a:7:{s:2:”id”;s:2:”33″;s:4:”zone”;s:1:”2″;s:5:”basis”;s:5:”price”;s:3:”min”;s:1:”0″;s:3:”max”;s:3:”200″;s:4:”cost”;s:2:”10″;s:7:”enabled”;s:1:”1″;}i:1;a:7:{s:2:”id”;s:2:”34″;s:4:”zone”;s:1:”2″;s:5:”basis”;s:5:”price”;s:3:”min”;s:3:”200″;s:3:”max”;s:1:”*”;s:4:”cost”;s:1:”0″;s:7:”enabled”;s:1:”1″;}i:2;a:7:{s:2:”id”;s:2:”35″;s:4:”zone”;s:1:”1″;s:5:”basis”;s:5:”price”;s:3:”min”;s:1:”0″;s:3:”max”;s:8:”272.6653″;s:4:”cost”;s:7:”13.6333″;s:7:”enabled”;s:1:”1″;}i:3;a:7:{s:2:”id”;s:2:”36″;s:4:”zone”;s:1:”1″;s:5:”basis”;s:5:”price”;s:3:”min”;s:8:”272.6653″;s:3:”max”;s:1:”*”;s:4:”cost”;s:1:”0″;s:7:”enabled”;s:1:”1″;}}

    I want to update it with my own values:

    $uk_update = ‘a:4:{i:0;a:7:{s:2:”id”;s:2:”17″;s:4:”zone”;s:1:”2″;s:5:”basis”;s:5:”price”;s:3:”min”;s:1:”0″;s:3:”max”;s:3:”200″;s:4:”cost”;s:2:”10″;s:7:”enabled”;s:1:”1″;}i:1;a:7:{s:2:”id”;s:2:”18″;s:4:”zone”;s:1:”2″;s:5:”basis”;s:5:”price”;s:3:”min”;s:3:”200″;s:3:”max”;s:1:”*”;s:4:”cost”;s:1:”0″;s:7:”enabled”;s:1:”1″;}i:2;a:7:{s:2:”id”;s:2:”19″;s:4:”zone”;s:1:”1″;s:5:”basis”;s:5:”price”;s:3:”min”;s:1:”0″;s:3:”max”;s:10:”‘.$uk_shipping_base.'”;s:4:”cost”;s:9:”‘.$uk_shipping_cost.'”;s:7:”enabled”;s:1:”1″;}i:3;a:7:{s:2:”id”;s:2:”20″;s:4:”zone”;s:1:”1″;s:5:”basis”;s:5:”price”;s:3:”min”;s:10:”‘.$uk_shipping_base.'”;s:3:”max”;s:1:”*”;s:4:”cost”;s:1:”0″;s:7:”enabled”;s:1:”1″;}}’;

    So I’m trying this:
    $wpdb->update( $wpdb->options, array(“option_value” => $uk_update), array(“option_id” => 1412), array(“%s”), array(“%d”) );

    But it is faulty and doesn’t work properly. Can somebody advise where is the mistake?

Viewing 1 replies (of 1 total)
  • Regan Khadgi

    (@regankhadgi)

    Hi there,

    The option values are saved in serialized format so you just can’t simply update using query for the serialized value.So first you should fetch that option using get_option.

    Then it should return you an array then you can study that array and change the required values in that array and then again use update_option to update the value in the option table.

    Thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘$wpdb to update option value’ is closed to new replies.