<?php $data = $_GET["address"]; $data = str_replace('\\', '', $data); $data = json_decode($data, true); $idFor = $data['idFor']; $class = $data['for']; $step = $data['step']; require_once '../model/address.php'; require_once '../model/' . $class . '.php'; $address = new address(); foreach ($_GET as $key => $value) { if ($key != "next" && $key != "address") { $nkey = "set" . ucfirst($key); $address->{$nkey}($value); } } $address->addToDatabase(); $item = new $class($idFor); $method = "setId_" . $step; $item->{$method}($address->getId()); $item->setToDatabase(); $result = array('idAddress' => $address->getId(), 'address' => $address->printAddress()); echo json_encode($result);
<?php require_once '../model/address.php'; require_once '../model/link_company_delivery_address.php'; //Création et ajout de l'adresse dans la base de données if ($_GET) { $naddress = new address(); foreach ($_GET as $key => $value) { if ($key != "id_company") { $nattr = "set" . ucfirst($key); $naddress->{$nattr}($value); } } $naddress->addToDatabase(); $id_address = $naddress->getId(); $id_company = $_GET["id_company"]; $nlcda = new link_company_delivery_address(); $nlcda->setId_company($id_company); $nlcda->setId_address($id_address); $nlcda->addToDatabase(); }
$pdo = database::getInstance(); $pdo = $pdo->PDOInstance; $stmt = $pdo->prepare('SELECT id FROM link_company_delivery_address WHERE id_company = :idc and id_address = :ida'); $stmt->bindParam(':idc', $id_c); $stmt->bindParam(':ida', $id_DA); $stmt->execute(); $result = $stmt->fetch(); $idLDA = $result['id']; $lda = new link_company_delivery_address($idLDA); $address = new address($lda->getId_address()); ?> <h2>Set this Address to Database</h2> <form method="get" action="../controller/setLinkDA.php"> <input type="hidden" name="idA" value="<?php echo $address->getId(); ?> "> <input type="hidden" name="idC" value="<?php echo $id_c; ?> "> <div class="form-group"> <label for="line">Line</label> <input type="text" class="form-control" name="line" value="<?php echo $address->getLine(); ?> "/> </div> <div class="form-group"> <label for="complement">Complement</label>
<?php require_once '../model/address.php'; $address = new address($_GET["id"]); foreach ($_GET as $key => $value) { if ($key != "next" && $key != "class" && $key != "step") { $nkey = "set" . ucfirst($key); $address->{$nkey}($value); } } $address->setToDatabase(); echo json_encode(array('id' => $address->getId(), 'address' => $address->printAddress()));