0

I have this funtion, basically is an insert, but I don't know how to bind work_date

    {
        $transacc = new mysqli($this->servername, $this->username, $this->password, $this->database);
        $query= $transacc->prepare("INSERT INTO workorder (vehicle_id, work_date
                workorder_description, amount) VALUES (?,?,?,?)");
        if ((empty($_POST['vehicle_id']) || empty($_POST['work_date']) || empty($_POST['workorder_description']) || empty($_POST['amount'])))
            echo "<p>Something went wrong</p>";
        else {
            $query->bind_param(
                'iisd',
                $_POST["vehicle_id"],
                $_POST["work_date"],
                $_POST["workorder_description"],
                $_POST["amount"]
            );
            $consultaInsercion->execute();
            $consultaInsercion->close();
        }
        $transacc->close();
    }

And this is the table

CREATE TABLE IF NOT EXISTS workorder (
    id INT NOT NULL AUTO_INCREMENT, 
    vehicle_id INT, 
    work_date DATE,
    workorder_description VARCHAR(300), 
    amount FLOAT, 
    PRIMARY KEY (id), 
    FOREIGN KEY (vehicle_id) REFERENCES vehicle(id), 
    CONSTRAINT date_vehicle UNIQUE (work_date,vehicle_id)
);

What is the correct way to bind the date?

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39

0 Answers0