<?php
 
// includes the file that contains data for connecting to mysql database, and  PDO_MySQLi class
 
include('../conn_mysql.php');
 
 
// creates object with connection to MySQL
 
$conn = new PDO_MySQLi($mysql);
 
 
// simple SELECT, without placeholders
 
$sql = "SELECT * FROM `testclass` WHERE `id` > 1";
 
 
// executes the SQL query (passing only the SQL query), and gets the selected rows
 
$rows = $conn->sqlExecute($sql);
 
 
$nr_rows = $conn->num_rows;          // number of selected rows
 
$nr_cols = $conn->num_cols;          // number of selected columns
 
 
// if there are returned rows, traverses the array with rows data, using foreach()
 
if($nr_rows > 0) {
 
  echo 'Number of selected rows: '. $nr_rows .' / Number of columns: '. $nr_cols;
 
 
  foreach($rows AS $row) {
 
    echo '<br/>ID = '. $row['id'] .' / Title = '. $row['title'];
 
  }
 
}
 
else {
 
  if($conn->error) echo $conn->error;      // if error, outputs it
 
  echo '0 selected rows';
 
}
 
 |