Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 120 | | All time: 9,501 This week: 42 |
|
Description | | Author |
This package can export MySQL records to a file to import in Excel.
It provides classes that can connect to a MySQL database using either the MySQLi or PDO extensions.
The example script can call these classes to execute queries to return results. Then it can export a file with a semi-colon separated data format containing the query result values. | |
|
|
Innovation award
Nominee: 2x
Winner: 1x |
|
Recommendations
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!";
}
?>
|
Details
A simple PHP :
- class Niger PDO
- class Niger MYSQLI
Export mysql data to excel spreadsheet or other formats using PDO or MYSQLI, PHP and MySQL .
It creates many files according to number of lines to define.
Before used thoses classes, below the prerequises :
The MySQLi or PDO extension is designed to work with MySQL version 4.1.13 or newer.
PHP 5 or newer
@From Africa / Niamey-Niger
@License GPL
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.