* 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()); echo 'Result: ', print_r($rs), PHP_EOL; /** * insert and get last_insert_id */ $db->PExecute('INSERT INTO tests (col1, col2) VALUES(?,?)', rand(), rand()); echo 'Last insert ID: ', $db->Insert_Id(); # ------------------------------------------------------------------------------ echo PHP_EOL, str_repeat('-', 80), PHP_EOL, 'Time: ', $timer->getPageLoadTime(), ' - Memory: ', $timer->getMemoryUsage(1), PHP_EOL, str_repeat('-', 80), PHP_EOL;