1

Currently, my code works if it has only one statement:

$stm = $conn->prepare("insert into my_table(a, b) values(?, ?)");
$stm->bind_param("ii", $a, $b);

Now I want to execute multiple statements at once to avoid round-trips.

$stm = $conn->prepare("delete my_table where a = ?; 
                      insert into my_table(a, b) values(?, ?)");
$stm->bind_param("iii", $a, $a, $b);

The code above doesn't work though.

dpp
  • 27,256
  • 30
  • 100
  • 152
  • Check that one http://stackoverflow.com/questions/11632902/mysqli-can-it-prepare-multiple-queries-in-one-statement and also a work around but without `prepare` in [here](http://www.php.net/manual/en/mysqli.multi-query.php) – Athafoud Jul 04 '14 at 07:10

1 Answers1

1

Assuming you are using mysqli library.

You are missing the execute bit

i.e. read http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php

Ed Heal
  • 57,599
  • 16
  • 82
  • 120
  • 4
    I think he omitted intentionally the `execute` command. But either way you can not `prepare` a multi-query with a single `prepare` statement. – Athafoud Jul 04 '14 at 07:15