PHP Classes

Niger: Query MySQL to generate data exports

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: 249 This week: 1All time: 7,938 This week: 34Up
Version License PHP version Categories
niger_class_php 1.5GNU General Publi...5Databases
Description 

Author

This class can query MySQL to generate data exports.

It can connect to MySQL using MySQLi and execute arbitrary queries.

It can create CSV files with data from database query results and have the files split when they exceed a given number of lines.

Picture of Hassane Moussa
  Performance   Level  
Name: Hassane Moussa <contact>
Classes: 10 packages by
Country: Niger Niger
Age: 40
All time rank: 21451 in Niger Niger
Week rank: 44 Up1 in Niger Niger Equal
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Recommendations

What is the best PHP export mysql to csv or excel class?
Export MySQL tables using PHP to Excel Ideally

What is the best PHP mysql report generator class?
How to generate report from MySQL data

PDO Class
I need a class to connect to my db (mysql). Now my code is a old

export mysql data to excel spreadsheet
export mysql data to excel csv or xls spreadsheet file

Generate XLS format
I need a package specialized the generation of XLS format file.

Import excel file (xlsx format) into mysql database
I need to import excel data into database

import ics files to mysql db
LINE CUT

export xlsx files
I want to export database records in xlsx format

What is the best PHP export excel class?
Trying to export query to an Excel file

Example

<?php

/***************************************************************************************
                                Using Functions of Niger Class
***************************************************************************************/
require_once('Niger.php');
// ini_set("memory_limit","10500M");
// set_time_limit(600);
 
$limit = 100; // number of rows in the file
 
$extension = ".csv"; // Extension File : ex : .txt ; .xls; .xlsx; ...
 
$filename = "Niger"; // the file name
 
 
$nigerconnect = new Niger ('localhost', 'root', '', 'adventureworks'); // Create a new object Niger
   
   
$Resulats = $nigerconnect->ReqSQL('SELECT * FROM `address` '); // request SQL
   
if ($Resulats){
   
$i =0;
   
$j = 1 ;
    foreach (
$Resulats as $Valeur)
    {
          if (
$nigerconnect->Modulo($i,$limit) ==0){
             
             
$newfile = $nigerconnect->CreatFile($filename,$extension,$j) ; // create new file
             
fputs($newfile, 'AddressID;AddressLine1;City'); // file header
             
fputs($newfile, "\r\n");
             
$j++;
          }
       
$i++;
              
fputs($newfile, '"'.$Valeur[0].'";"'.$Valeur[1].'";"'.$Valeur[3].'"'); // put the data from database in the file
              
fputs($newfile, "\r\n");
               if (
$nigerconnect->Modulo($i,$limit) ==0){fclose($newfile);} // close file
              

   
} // foreach
   
echo "You succeed ! Congratulations.";
    }
// if
   
else {
        echo
"You did not succeed.Check your sql!";
    }
?>


  Files folder image Files (8)  
File Role Description
Accessible without login Plain text file LICENSE Lic. License text
Plain text file Niger.php Class Class source
Plain text file nigerPdo.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file readme.txt Doc. Documentation
Accessible without login Plain text file UsingFunctionsOfNigerClass.php Example Example script
Accessible without login Plain text file UsingFunctionsOfNigerPdoClass.php Example Example script
Accessible without login Plain text file _config.yml Data Auxiliary data

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
Downloadniger_class_php-2019-01-23.zip 16KB
Downloadniger_class_php-2019-01-23.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
PHP Forms Class with HTML Generator and JavaScript Validation Download .zip .tar.gz the package is compulsory Required
 Version Control Unique User Downloads Download Rankings  
 100%
Total:249
This week:1
All time:7,938
This week:34Up