PHPackages                             vijaykumar/sql-to-csv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. vijaykumar/sql-to-csv

ActiveLibrary[Database &amp; ORM](/categories/database)

vijaykumar/sql-to-csv
=====================

This package help you to generates csv files using sql queries.

06PHP

Since Apr 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Vijaykumar308/generate-csv)[ Packagist](https://packagist.org/packages/vijaykumar/sql-to-csv)[ RSS](/packages/vijaykumar-sql-to-csv/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Generate CSV
============

[](#generate-csv)

This code is a PHP function that generates a CSV file from a SELECT query result and allows the user to download it. It utilizes the PHP `fputcsv` function to write data to the CSV file.

Prerequisites
-------------

[](#prerequisites)

- PHP version 5.6.0 or higher
- PDO extension enabled

Install Package
---------------

[](#install-package)

composer require vijaykumar/sql-to-csv:dev-master@dev

Usage
-----

[](#usage)

1. Include the code file containing the `generate_csv` function in your PHP project.
2. Create a database connection object using PDO and pass it as the first parameter to the `generate_csv` function.
3. Provide a valid SELECT query as the second parameter to the `generate_csv` function. Only SELECT queries are allowed.
4. Specify an optional filename as the third parameter to the `generate_csv` function. If not provided, the default filename will be "Report.csv".
5. Call the `generate_csv` function to generate the CSV file and initiate the download.

### Example

[](#example)

```

```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/97676454?v=4)[Vijay Kumar](/maintainers/Vijaykumar308)[@Vijaykumar308](https://github.com/Vijaykumar308)

---

Top Contributors

[![Vijaykumar308](https://avatars.githubusercontent.com/u/97676454?v=4)](https://github.com/Vijaykumar308 "Vijaykumar308 (13 commits)")

---

Tags

generate-csvpackagephpsqlsql-to-csv

### Embed Badge

![Health badge](/badges/vijaykumar-sql-to-csv/health.svg)

```
[![Health](https://phpackages.com/badges/vijaykumar-sql-to-csv/health.svg)](https://phpackages.com/packages/vijaykumar-sql-to-csv)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
