1. 云栖社区>
  2. PHP教程>
  3. 正文

PHP订单操作 serialize

作者:用户 来源:互联网 时间:2017-12-01 17:35:58

php订单操作serialize

PHP订单操作 serialize - 摘要: 本文讲的是PHP订单操作 serialize,   **************Action//添加订单行信息 function addRequireLine ($mapping, $form, &$request, &$response){ $arr_rq_info


 



**************
Action
//添加订单行信息
function addRequireLine ($mapping, $form, &$request, &$response){
$arr_rq_info = $request->getParameter('rqInfo');//提交序列化订单信息来更新
if(MAGIC_QUOTES_GPC){
$require_info= stripslashes($arr_rq_info);
}
$require_info= unserialize ($arr_rq_info);
if(!$require_info){
$require_info = array(
'prj_id' => null,
'ref' => null,
'create_time' => null,
'building' => null, //以上是存订单头信息
'lineItems' => array(), //添加lineItems的index放订单行信息
);
}
$option = $request->getParameter('option');
$aryRq = $form->aryRequireJob;//订单头信息
$aryRqLines = $form->aryRequireLines;////订单行信息
$rqInfo = $this->delegate->addRequireJobLine($aryRq, $option, $aryRqLines, $require_info);
$form->setSessRequire($rqInfo); //将更新后订单信息传到页面
$this->init ($mapping, $form, &$request, &$response);
$request->setAttribute('ACTION_FORM',$form);
return $mapping->findForwardConfig('success');
}
//编辑订单行信息
function editRequireLine ($mapping, $form, &$request, &$response){
$arr_rq_info = $request->getParameter('rqInfo');
$require_info = unserialize($arr_rq_info);
$lineNo = $request->getParameter('num');
$option = $request->getParameter('option');
$aryRq = $form->aryRequireJob;
$aryRqLines = $form->aryRequireLines;
if($require_info){
$rqInfo = $this->delegate->editRequireJobLine($lineNo, $option, $aryRq, $aryRqLines, $require_info);
}
$form->setSessRequire($rqInfo);
$this->init ($mapping, $form, &$request, &$response);
$request->setAttribute('ACTION_FORM',$form);
return $mapping->findForwardConfig('success');
}
******manager********
function addArrayRequireLine($aryRequire, $option, $aryRequireLines, $rqInfo){
$rqInfo['prj_id'] = $aryRequire['prj_id'];
$rqInfo['ref'] = $aryRequire['ref'];
$rqInfo['create_time'] = $aryRequire['create_time'];
$rqInfo['building'] = $aryRequire['building'];
array_push($rqInfo['lineItems'],array(
'stock_code' => $aryRequireLines['stock_code'],
'stock_name' => $aryRequireLines['stock_name'],
'stock_detail' => $aryRequireLines['stock_detail'],
'supplier_name' => $aryRequireLines['supplier_name'],
'building' => $aryRequireLines['building'],
'delivery_to' => $aryRequireLines['delivery_to'],
'qty' => $aryRequireLines['qty'],
'remark' => $aryRequireLines['remark']
)
);
return $rqInfo;
}
function editArrayRequireLine($lineNo, $option, $aryRequire, $aryRequireLines, $rqInfo){
$rqInfo['prj_id'] = $aryRequire['prj_id'];
$rqInfo['ref'] = $aryRequire['ref'];
$rqInfo['create_time'] = $aryRequire['create_time'];
$rqInfo['building'] = $aryRequire['building'];
$rqInfo['lineItems'][$lineNo]['stock_code'] = $aryRequireLines['stock_code'];
$rqInfo['lineItems'][$lineNo]['stock_name'] = $aryRequireLines['stock_name'];
$rqInfo['lineItems'][$lineNo]['stock_detail'] = $aryRequireLines['stock_detail'];
$rqInfo['lineItems'][$lineNo]['supplier_name']= $aryRequireLines['supplier_name'];
$rqInfo['lineItems'][$lineNo]['building'] = $aryRequireLines['building'];
$rqInfo['lineItems'][$lineNo]['delivery_to'] = $aryRequireLines['delivery_to'];
$rqInfo['lineItems'][$lineNo]['qty'] = $aryRequireLines['qty'];
$rqInfo['lineItems'][$lineNo]['remark'] = $aryRequireLines['remark'];
return $rqInfo;
}
function deleteArrayRequireLine($lineNo, $rqInfo){
unset($rqInfo['lineItems'][$lineNo]);
return $rqInfo;
}
function replace_require_index($LineNo, $LineNoAfter, $rqInfo){
$rqInfo['lineItems'][$LineNo]= $rqInfo['lineItems'][$LineNoAfter];
deleteArrayRequireLine($LineNoAfter, $rqInfo){
return $rqInfo;
}
*******delegate*****
function addRequireJobLine($aryRequire, $option, $aryRequireLines, $rqInfo){
return $this->data_manager->addArrayRequireLine($aryRequire, $option, $aryRequireLines, $rqInfo);
}
function editRequireJobLine($lineNo, $option, $aryRequire, $aryRequireLines, $rqInfo){
return $this->data_manager->editArrayRequireLine($lineNo, $option, $aryRequire, $aryRequireLines, $rqInfo);
}
//删除订单行后,重组数组key(数组key对应的是订单行号信息,所以要重组)
function deleteOutRqJobLine($lineNo, $lineCounter, $rqInfo){
if(($lineNo+1)==$lineCounter){
$rqInfo = $this->data_manager->deleteOutRequireLine($lineNo, $rqInfo);
}
if(($lineNo+1)<$lineCounter){
$rqInfo = $this->data_manager->deleteOutRequireLine($lineNo, $rqInfo);
for($i=($lineNo+1);$i<$lineCounter;$i++){
$rqInfo = $this->data_manager->replace_outrq_index(($i-1), $i, $rqInfo);
}
}
return $rqInfo;
}
 

方法二:将订单行的操作与不做交互,用js去更新页面值。点击保存订单存数据库,才做交互,方法二较一要好http://hudeyong926.iteye.com/admin/blogs/608030

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索php , 订单 , 操作 serialize ,以便于您获取更多的相关知识。