Prepare

Prepare arguments for the Prepared Statements PExecute method.

Parameters

Prepare($arg= null)

$arg argument to be used in the PExecute method, if no input it will return the array with the prepared statements

The prepare method automatically detect the input type, you can also override this, using something like: Prepare('s','1e1')

Example building dynamic queries that require prepared statements:

$X = 3;
$id = 1;
$db->Prepare($id);
$sql = 'SELECT * FROM test WHERE id=? ';
if ($X == 3) {
  $db->Prepare($X);
  $sql .= 'AND id !=? ';
}
$db->Prepare('s', 'colb');
$sql .= 'AND colB=?';
}

/**
 * this will produce a query like:
 * "sql: SELECT * FROM test WHERE id=? AND id !=? AND colB=?" with params = ["iis",1,3,"colb"]
 */
$rs = $db->PgetAll($sql, $db->Prepare());

comments powered by Disqus