本文整理匯總了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;
}