<?php
// @ PDO Prepared MySQL Statements Class v2.0 - Example
// @ Developed by Takis Maletsas
// @ 2016
require_once 'pdo.class.php';
try {
$db = new DB;
$db->query("CREATE TABLE my_table ( col1 VARCHAR(255), col2 INT, col3 VARCHAR(5) )");
$db->query("INSERT INTO my_table (col1,col2,col3) VALUES (?,?,?)", "Value1", 123, true);
$rows = $db->fetch("SELECT * FROM my_table WHERE col1=?", "Value1");
echo $rows[0]['col2'] . "</br>";
var_dump($rows[0]);
var_dump($rows);
$rows = $db->fetch("SELECT * FROM my_table WHERE col2=? AND col3=?", 123, true);
echo $rows[0]['col1'] . "</br>";
var_dump($rows[0]);
var_dump($rows);
$db->query("UPDATE my_table SET col1=?, col3=? WHERE col2=?", "Value2", true, 123);
$rows = $db->fetch("SELECT * FROM my_table");
echo $rows[0]['col1'] . "</br>";
var_dump($rows[0]);
var_dump($rows);
}
catch (Exception $e) {
exit($e->getMessage());
}
?>
|