本文整理汇总了PHP中common_node::updateSingleAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP common_node::updateSingleAttribute方法的具体用法?PHP common_node::updateSingleAttribute怎么用?PHP common_node::updateSingleAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common_node
的用法示例。
在下文中一共展示了common_node::updateSingleAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mainAction
/**
* main action
*/
public function mainAction()
{
/**
* TODO:
* implement general updateSingleAttribute()
*/
//print_r($_POST);
$model = $this->GET['model'];
$attribute = $this->GET['attribute'];
$update_value = trim($_POST['update_value']);
$original_value = trim($_POST['original_html']);
// currently implemented for product_variety.name and price.value
switch ($model) {
case 'common_node':
require_once 'models/common/common_node.php';
$element_id_parts = explode('-', $_POST['element_id']);
$variety_id = $element_id_parts[3];
$ModelObj = new common_node();
if (!$ModelObj->updateSingleAttribute($attribute, $update_value, $variety_id)) {
msg('Failed', 'error');
}
break;
case 'ecommerce_product_variety':
require_once 'models/ecommerce/ecommerce_product_variety.php';
$element_id_parts = explode('-', $_POST['element_id']);
$variety_id = $element_id_parts[3];
$ModelObj = new ecommerce_product_variety();
if (!$ModelObj->updateSingleAttribute($attribute, $update_value, $variety_id)) {
msg('Failed', 'error');
}
break;
case 'ecommerce_price':
require_once 'models/ecommerce/ecommerce_price.php';
$ModelObj = new ecommerce_price();
$element_id_parts = explode('-', $_POST['element_id']);
$variety_id = $element_id_parts[3];
$last_price = $ModelObj->getLastPriceForVariety($variety_id);
//remove anything else than number and decimal point
$update_value = preg_replace("/[^0-9\\.]*/", '', $update_value);
//update only when the new price is different than old price
if (round($last_price['value'], 2) != round($update_value, 2)) {
if (!$ModelObj->updateSingleAttribute('value', $update_value, $last_price['id'])) {
msg('Failed', 'error');
}
}
break;
case 'international_translation':
require_once 'models/international/international_translation.php';
$element_id_parts = explode('-', $_POST['element_id']);
$updated_id = $element_id_parts[3];
$ModelObj = new international_translation();
if (!$ModelObj->updateSingleAttribute($attribute, $update_value, $updated_id)) {
msg('Failed', 'error');
}
break;
default:
return false;
break;
}
if ($update_value != $original_value) {
$value = $update_value;
} else {
$value = $original_value;
}
$this->tpl->assign('VALUE', $value);
return true;
}