PHP Classes

MySQL Query Result Iterator: Run MySQLi queries and return iterator objects

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 204 All time: 8,443 This week: 488Up
Version License PHP version Categories
basic-mysql 7Freeware7Databases, PHP 7
Description 

Author

This class can run MySQLi queries and return iterator objects.

It can connect to a given MySQL database using MySQLi and execute SQL queries.

The class returns as result an object of an anonymous class that can iterate over the query results and return result data records and other details.

Picture of Sergio Soares
  Performance   Level  

 

Example

<?php
declare(strict_types=1);

// Include MySQL class
require_once('inc/basicmysql.class.php');
// Include database connection
require_once('inc/global.inc.php');

function
showProfile() {
   
    global
$DB;

    if (
$result = $DB->query("SELECT id, name, age, number FROM profile")){
       
        if (!
defined('TABLE')) define ('TABLE',['id','name','age','number']);
       
        while (
$sqlReg=$result->fetch()) {
       
            echo(
"<p>Candidate with ID \"".$sqlReg[TABLE[0]]."\" named ".$sqlReg[TABLE[1]].
                   
" with ".$sqlReg[TABLE[2]]." years old with mobile ".$sqlReg[TABLE[3]].
                   
" may wait for interview.</p>");
           
        }
       
    }
}


showProfile();

?>


Details

basicmysqli-class

Basic MySQL Class for PHP 7

This class can run MySQLi queries and return iterator objects.

It can connect to a given MySQL database using MySQLi and execute SQL queries.

The class returns as result an object of an anonymous class that can iterator over the query results and return result data records and other details.


  Files folder image Files (6)  
File Role Description
Files folder imageinc (2 files)
Plain text file index.php Example Example script
Plain text file basicsqli.sql Data Auxiliary data
Plain text file README.md Data Auxiliary data
Plain text file basicmysql.class.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:204
This week:0
All time:8,443
This week:488Up