Exemple #1
0
 private function gravaDataEntrega(knl_extensions_dpedcompra_model $PedCompra, $dataentrega)
 {
     $PedCompraEntrega = knl_extensions_dpedcompra_daoPedCompraEntrega::getInstance();
     $PedCompraEntrega->deleteByIdPedCompra($PedCompra->get_id());
     $mPedCompraEntrega = new knl_extensions_dpedcompra_modelPedCompraEntrega(0, $PedCompra->get_id(), "");
     foreach ($dataentrega as $v) {
         $v = $this->data_br_to_mysql($v);
         if ($v != "0000-00-00" and $v != "00-00-00") {
             $mPedCompraEntrega->set_id(0);
             $mPedCompraEntrega->set_dataentrega($v);
             $PedCompraEntrega->upsert($mPedCompraEntrega);
         }
     }
 }
 public function upsert(knl_extensions_dpedcompra_modelPedCompraEntrega $objmodel)
 {
     if ($objmodel->get_id() == 0) {
         $query = "INSERT INTO d_ped_compra_entrega (id_d_ped_compra,dataentrega)\n                    VALUES ('" . $objmodel->get_id_d_ped_compra() . "','" . $objmodel->get_dataentrega_db() . "')";
         $stmt = $this->conn->prepare($query);
         $stmt = $this->conn->execute($stmt);
         $objmodel->set_id($this->conn->Insert_ID());
     } else {
         $query = "UPDATE d_ped_compra_entrega SET \n                      id_d_ped_compra='{$objmodel->get_id_d_ped_compra()}',dataentrega='{$objmodel->get_dataentrega_db()}'\n                      WHERE id = ?";
         $stmt = $this->conn->prepare($query);
         $stmt = $this->conn->execute($stmt, $objmodel->get_id());
     }
     return $objmodel;
 }