<?php
try
{
// require class
require_once ('class.pablosky_mysql.php');
// new object
$mysqli = new pablosky_mysql ('localhost', 'root', '', 'pablosky_mysql_test');
// insert
$insert = $mysqli->set_query ("INSERT INTO table1 (name) VALUES ('pablo'), ('juan')");
echo "<p>ID last sentence: $insert</p>";
// get_results
$results = $mysqli->get_results ("SELECT * FROM table1");
foreach ($results as $result)
{
echo '<p>'.$result->id_name.' '.$result->name.'</p>';
}
// num_results
$num_results = $mysqli->get_num_rows();
echo "<p>Num results: $num_results</p>";
// num_fields
$num_fields = $mysqli->get_num_fields();
echo "<p>Num fields: $num_fields</p>";
// get_record
$result = $mysqli->get_record ("SELECT * FROM table1 WHERE id_name = 1");
echo '<p>'.$result->id_name.' '.$result->name.'</p>';
}
catch (Exception $ex)
{
echo '<p>Exception Caught: ' . $ex->getMessage() . '<p>Trace: ' . $ex->getTraceAsString() . '</p>';
}
?>
|