<?php
// Database Connection
require_once('../../includes/connection.php');
// Connect to Database Using MySQL
$conn = dbConnect('read', 'pdo');
// Prepare the SQL query
$sql = 'SELECT *
FROM php_a04_images
';
// Submit the Query and Capture the Result
$result = $conn->query($sql);
// Check for PHP Data Object (PDO) Errors
$error = $conn->errorInfo()[2];
// Check For Database Errors
if (!$error) {
$numRows = $result->rowCount();
}
$tools = true;
include("../../includes/header.php");
?>
<main>
<h2><?php echo $folder_name; ?><span><?php echo $file_name; ?></span></h2>
<p><a href="https://www.php.net/manual/en/class.pdostatement.php">php.net | The PDOStatement class</a></p>
<?php
if (isset($error)) {
echo "<p class=\"error\">$error</p>";
} else {
echo "<p class=\"info\">A total of $numRows records were found.</p>";
}
?>
<figure class="code">
<pre class="language-sql"><code><?= $sql ?></code></pre>
</figure>
<h2>Debug Code - var_dump($conn)</h2>
<pre class="line-numbers">
<code class="language-php">
<?php var_dump($conn); ?>
</pre>
</code>
<h2>Debug Code - var_dump($conn->getAttribute())</h2>
<pre class="line-numbers">
<code class="language-php">
<?php
$attributes = [
"AUTOCOMMIT",
"ERRMODE",
"CASE",
"CLIENT_VERSION",
"CONNECTION_STATUS",
"EMULATE_PREPARES",
"ORACLE_NULLS",
"PERSISTENT",
"SERVER_INFO",
"SERVER_VERSION"
];
foreach ($attributes as $val) {
echo "PDO::ATTR_$val: \n";
echo $conn->getAttribute(constant("PDO::ATTR_{$val}")) . "\n\n";
}
?>
</pre>
</code>
<h2>Debug Code - $conn->errorInfo()</h2>
<pre class="line-numbers">
<code class="language-php">
<?php var_dump($conn->errorInfo()); ?>
</pre>
</code>
<h2>Debug Code - var_dump($result)</h2>
<pre class="line-numbers">
<code class="language-php">
<?php var_dump($result); ?>
</pre>
</code>
</main>
<?php
# The side-bar section of the layout use custom path to load from a different folder.
include("../../includes/sidebar.php");
# The footer section of the layout.
include("../../includes/footer.php");
?>