04 Sessions Mysql 20 2.01 Mysqli_01

04 Sessions Mysql20 2.01 Mysqli_01

php.net | MySQL Improved Extension

A total of 8 records were found.

SELECT * 
FROM php_a04_images

Debug Code - var_dump($conn)


object(mysqli)#1 (18) {
  ["affected_rows"]=>
  int(8)
  ["client_info"]=>
  string(14) "mysqlnd 8.1.30"
  ["client_version"]=>
  int(80130)
  ["connect_errno"]=>
  int(0)
  ["connect_error"]=>
  NULL
  ["errno"]=>
  int(0)
  ["error"]=>
  string(0) ""
  ["error_list"]=>
  array(0) {
  }
  ["field_count"]=>
  int(3)
  ["host_info"]=>
  string(25) "Localhost via UNIX socket"
  ["info"]=>
  NULL
  ["insert_id"]=>
  int(0)
  ["server_info"]=>
  string(32) "10.3.39-MariaDB-0ubuntu0.20.04.2"
  ["server_version"]=>
  int(100339)
  ["sqlstate"]=>
  string(5) "00000"
  ["protocol_version"]=>
  int(10)
  ["thread_id"]=>
  int(476898)
  ["warning_count"]=>
  int(0)
}

Debug Code - mysqli Methods


Array
(
    [0] => __construct
    [1] => autocommit
    [2] => begin_transaction
    [3] => change_user
    [4] => character_set_name
    [5] => close
    [6] => commit
    [7] => connect
    [9] => debug
    [8] => dump_debug_info
    [27] => escape_string
    [10] => get_charset
    [11] => get_client_info
    [12] => get_connection_stats
    [13] => get_server_info
    [14] => get_warnings
    [15] => init
    [16] => kill
    [18] => more_results
    [17] => multi_query
    [19] => next_result
    [34] => options
    [20] => ping
    [21] => poll
    [22] => prepare
    [23] => query
    [24] => real_connect
    [25] => real_escape_string
    [28] => real_query
    [26] => reap_async_query
    [42] => refresh
    [29] => release_savepoint
    [30] => rollback
    [31] => savepoint
    [32] => select_db
    [33] => set_charset
    [35] => set_opt
    [36] => ssl_set
    [37] => stat
    [38] => stmt_init
    [39] => store_result
    [40] => thread_safe
    [41] => use_result
)

Debug Code - var_dump($result)


object(mysqli_result)#2 (5) {
  ["current_field"]=>
  int(0)
  ["field_count"]=>
  int(3)
  ["lengths"]=>
  NULL
  ["num_rows"]=>
  int(8)
  ["type"]=>
  int(0)
}

Debug Code - mysqli_result Methods


Array
(
    [0] => __construct
    [1] => close
    [3] => data_seek
    [7] => fetch_all
    [8] => fetch_array
    [9] => fetch_assoc
    [12] => fetch_column
    [4] => fetch_field
    [6] => fetch_field_direct
    [5] => fetch_fields
    [10] => fetch_object
    [11] => fetch_row
    [13] => field_seek
    [2] => free
    [14] => free_result
    [15] => getIterator
)
$_SERVER["SCRIPT_NAME"]
/php/assignments/04-sessions-mysql/20-2.01-mysqli_01.php

print_r($_GET)
Array
(
)


print_r($_POST)
Array
(
)


print_r($_SESSION)
Array
(
)


print_r($_FILES)
Array
(
)



<?php
// Database Connection
require_once('../../includes/connection.php');

// Connect to Database Using MySQL
$conn dbConnect('read');

// $conn is an Object of the mysqli Class
//var_dump($conn);
//exit();

// Prepare the SQL query
$sql 'SELECT * 
FROM php_a04_images
'
;

// Submit the Query and Capture the Result
$result $conn->query($sql);

// Check For Database Errors
if (!$result) {
    
$error $conn->error;
} else {
    
// find out how many records were retrieved
    
$numRows $result->num_rows;
}

$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/book.mysqli.php">php.net | MySQL Improved Extension</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 - <?= get_class($conn?> Methods</h2>
    <pre class="line-numbers">
<code class="language-php">
<?php $conn_methods get_class_methods(get_class($conn)); ?>
<?php asort
($conn_methods); ?>
<?php print_r
($conn_methods); ?>
</pre>
    </code>

    <h2>Debug Code - var_dump($result)</h2>
    <pre class="line-numbers">
<code class="language-php">
<?php var_dump($result); ?>
</pre>
    </code>

    <h2>Debug Code - <?= get_class($result?> Methods</h2>
    <pre class="line-numbers">
<code class="language-php">
<?php $result_methods get_class_methods(get_class($result)); ?>
<?php asort
($result_methods); ?>
<?php print_r
($result_methods); ?>
</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");
?>