# Prepared Statement And `mysqli`
+ **`mysqli_stmt`** class represents a prepared statement
+ Prepare phase:
  + Create the `SQL` statement with question marks to represent the values that will change with each execution, for example:
    + **`$sqlStmt = "INSERT INTO pdo_t1 (c1, c2)" . " VALUES (?, ?)"`**
  + Create a prepared statement object, an instance of **`mysql_stmt`** class:
    + **`$stmt = $mysqli->prepare($sqlStmt)`**
  + Bind variables that contain the values for the question marks, both variables are in string type **`"s"`** in this example:
    + **`$stmt->bind_param("ss", $v1, $v2)`**
+ Execute phase:
  + Assign values to bind variables, for this example:
    + **`$v1 = "V1"`**
    + **`$v2 = "V2"`**
  + Call method **`$stmt->execute()`** to execute
-----------------------------------------------------------------------------------
To create a prepared statement in `mysqli`, write the SQL using placeholders for the values that will change with each execution. 

The example in the slide uses question marks to do this instead of named placeholders. 

When you have prepared a statement, get it ready for execution by setting values for each placeholder using the `bind_param()` method. 

Execute a prepared statement by using the statement object’s `execute()` method, regardless of whether the statement is a query that returns rows or not.

After executing the statement and reading its returned values, assign new values to the placeholders and re-execute the prepared statement without preparing it again. When you are finished with the prepared statement, close it with `$stmt->close()`.
