当前位置: 首页>>代码示例>>PHP>>正文


PHP Pedido::Save方法代码示例

本文整理汇总了PHP中Pedido::Save方法的典型用法代码示例。如果您正苦于以下问题:PHP Pedido::Save方法的具体用法?PHP Pedido::Save怎么用?PHP Pedido::Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pedido的用法示例。


在下文中一共展示了Pedido::Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Create

 /**
  * API Method inserts a new Pedido record and render response as JSON
  */
 public function Create()
 {
     try {
         $json = json_decode(RequestUtil::GetBody());
         if (!$json) {
             throw new Exception('The request body does not contain valid JSON');
         }
         $pedido = new Pedido($this->Phreezer);
         // TODO: any fields that should not be inserted by the user should be commented out
         // this is an auto-increment.  uncomment if updating is allowed
         // $pedido->Id = $this->SafeGetVal($json, 'id');
         $pedido->Datacriacao = date('Y-m-d H:i:s', strtotime($this->SafeGetVal($json, 'datacriacao')));
         $pedido->Observacao = $this->SafeGetVal($json, 'observacao');
         $pedido->Dataentrega = date('Y-m-d H:i:s', strtotime($this->SafeGetVal($json, 'dataentrega')));
         $pedido->Valorfrete = $this->SafeGetVal($json, 'valorfrete');
         $pedido->Valordesconto = $this->SafeGetVal($json, 'valordesconto');
         $pedido->Valortotal = $this->SafeGetVal($json, 'valortotal');
         $pedido->Statuspedido = $this->SafeGetVal($json, 'statuspedido');
         $pedido->Formapagamento = $this->SafeGetVal($json, 'formapagamento');
         $pedido->Vendedor = $this->SafeGetVal($json, 'vendedor');
         $pedido->Cliente = $this->SafeGetVal($json, 'cliente');
         $pedido->Enderecoentrega = $this->SafeGetVal($json, 'enderecoentrega');
         $pedido->Itempedido = $this->SafeGetVal($json, 'itempedido');
         $pedido->Validate();
         $errors = $pedido->GetValidationErrors();
         if (count($errors) > 0) {
             $this->RenderErrorJSON('Please check the form for errors', $errors);
         } else {
             $pedido->Save();
             $this->RenderJSON($pedido, $this->JSONPCallback(), true, $this->SimpleObjectParams());
         }
     } catch (Exception $ex) {
         $this->RenderExceptionJSON($ex);
     }
 }
开发者ID:ronyelias,项目名称:pizzaria,代码行数:38,代码来源:PedidoController.php

示例2: Create

 /**
  * API Method inserts a new Pedido record and render response as JSON
  */
 public function Create()
 {
     try {
         $json = json_decode(RequestUtil::GetBody());
         if (!$json) {
             throw new Exception('The request body does not contain valid JSON');
         }
         $pedido = new Pedido($this->Phreezer);
         // TODO: any fields that should not be inserted by the user should be commented out
         // this is an auto-increment.  uncomment if updating is allowed
         // $pedido->Id = $this->SafeGetVal($json, 'id');
         $pedido->ProdutoId = $this->SafeGetVal($json, 'produtoId');
         $pedido->ClienteId = $this->SafeGetVal($json, 'clienteId');
         $pedido->Validate();
         $errors = $pedido->GetValidationErrors();
         if (count($errors) > 0) {
             $this->RenderErrorJSON('Please check the form for errors', $errors);
         } else {
             $pedido->Save();
             $this->RenderJSON($pedido, $this->JSONPCallback(), true, $this->SimpleObjectParams());
         }
     } catch (Exception $ex) {
         $this->RenderExceptionJSON($ex);
     }
 }
开发者ID:DaviRoberto,项目名称:testes,代码行数:28,代码来源:PedidoController.php


注:本文中的Pedido::Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。