Esempio n. 1
0
 * helpful in cases where searching float values stored on varchar fields
 * $db->PGetAll($sql, array('s' => 99.3, 1));
 */
$sql = 'SELECT * FROM tests WHERE id=? AND col1=?';
$rs = $db->PGetAll($sql, array(3, 's' => 'string'));
var_dump($rs);
/**
 * using the Prepare method,
 * Useful when building dynamic queries that require prepared statements
 * The prepare method automatically detect the input type,
 * you can also override this, using something like: Prepare('s','1e1');
 * if no input it will return the array with the prepared statements
 */
$X = 3;
$id = 1;
$db->Prepare($id);
$sql = 'SELECT * FROM tests WHERE id=? ';
if ($X == 3) {
    $db->Prepare($X);
    $sql .= 'AND id !=? ';
}
$db->Prepare('s', 'ai eu');
$sql .= 'AND col1=?';
/**
 * this will produce a query like:
 * "sql: SELECT * FROM tests WHERE id=? AND id !=? AND col1=?" with params = ["iis",1,3,"ai eu"]
 */
echo "sql: {$sql}", PHP_EOL;
echo 'Args: ', PHP_EOL;
print_r($db->Prepare());
$rs = $db->PgetAll($sql, $db->Prepare());