PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 204 All time: 8,435 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  
Name: Sergio Soares <contact>
Classes: 3 packages by
Country: Portugal Portugal
Age: 47
All time rank: 150920 in Portugal Portugal
Week rank: 311 Up4 in Portugal Portugal Up

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  
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

  Files folder image Files  /  inc  
File Role Description
  Plain text file basicmysql.class.php Class Class source
  Plain text file global.inc.php Conf. Configuration script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:204
This week:0
All time:8,435
This week:488Up