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 1mo ago

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://www.gravatar.com/avatar/a44763d7bde31b4e985fe676960b8f3f74a6a0a32f8add13ec8b01508168bb5d?d=identicon)[Vijaykumar308](/maintainers/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

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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