Update Promotions

I want to upgrade a promotion directly into the database when the update does not apply discounts.



$toDate = strtotime($toDate);

$fromDate = strtotime($fromDate);



$bonuses = (string)'a:1:{i:1;a:3:{s:5:“bonus”;s:16:“product_discount”;s:14:“discount_bonus”;s:13:“to_percentage”;s:14:“discount_value”;s:'. strlen($porcentaje) .':“'. $porcentaje .'”;}}';



echo"--------BONUS -------
“;

echo”-------- $bonuses -------
";

$actualizacion = "UPDATE cscart_promotions

SET bonuses = '$bonuses',

to_date = $toDate,

from_date = $fromDate,

status = '$estado' WHERE promotion_id = $promotion_id ";

Don't know what you mean in your opening sentence.

Are you just wanting to change the period (from/to)? If so, why update the other fields?

@ComputoGessacr,



What is the question?

I want to update this data on the database [color=#282828][font=arial, verdana, tahoma, sans-serif]bonuses = '$bonuses', [/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]to_date = $toDate, [/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]from_date = $fromDate,[/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]status` = '$estado'[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]becouse we use too many promotions i have to create a script that upgrade more than 25 promotions but Whe i upgrade the promotions they do not work.[/font][/color]

[quote name='ComputoGessacr' timestamp='1400679161' post='183980']

I want to update this data on the database [color=#282828][font=arial, verdana, tahoma, sans-serif]bonuses = '$bonuses', [/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]to_date = $toDate, [/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]from_date = $fromDate,[/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]status` = '$estado'[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]becouse we use too many promotions i have to create a script that upgrade more than 25 promotions but Whe i upgrade the promotions they do not work.[/font][/color]

[/quote]



It will be better to receive the actual bonuse in the following way:



$actual_bonuses = db_get_field("SELECT bonuses FROM ?:promotions WHERE promotion_id = ?i", $promotion_id);




Then transform the received value to an array:



$actual_bonuses = unserialize($actual_bonuses);




Make the necessary changes in the array, serialize it and put back to the database.



Hope that helps.

[quote name=‘eComLabs’ timestamp=‘1400683870’ post=‘183991’]

It will be better to receive the actual bonuse in the following way:


<br />
$actual_bonuses = db_get_field("SELECT bonuses FROM ?:promotions WHERE promotion_id = ?i", $promotion_id);<br />

```<br />
<br />
Then transform the received value to an array:<br />
<br />
```php
<br />
$actual_bonuses  = unserialize($actual_bonuses);<br />

```<br />
<br />
Make the necessary changes in the array, serialize it and put back to the database.<br />
<br />
Hope that helps.<br />
[/quote]<br />
<br />
Thanks it works correctly <img src="upload://iKNGSw3qcRIEmXySa8gItY6Gczg.gif" class="bbc_emoticon" alt=":grin:">