Skip to content

imransaadullah/fast-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fast-sql

fast-sql is a PHP class designed to provide a secure and flexible way to generate SQL queries. It supports various SQL operations, parameter binding to prevent SQL injection, transactions, and caching for improved performance.

Installation

You can install fast-sql using Composer. Add the following to your composer.json file:

{
    "require": {    
        "progrmanial/fast-sql": "dev-master"
    }
}

Then run:

composer install

Usage

<?php

use progrmanial\FASTSQL\SecureSQLGenerator;
use PDO;

// Create a PDO instance for mysql database connection
$pdo = new PDO('mysql:host=localhost;dbname=your_database', 'username', 'password');

// Create an instance of SecureSQLGenerator
$sqlGenerator = new SecureSQLGenerator($pdo);

// Example: SELECT operation
$result = $sqlGenerator
    ->select(['id', 'name'])
    ->from('users')
    ->where(['status' => 'active'])
    ->execute();

// Example: INSERT operation
$sqlGenerator
    ->insert('products', ['name' => 'Product A', 'price' => 29.99])
    ->execute();

// Example: JOIN operation
$result = $sqlGenerator
    ->select(['users.id', 'users.name', 'orders.total'])
    ->from('users')
    ->innerJoin('orders', ['users.id' => 'orders.user_id'])
    ->execute();

Features

  • Secure: Uses parameter binding to prevent SQL injection.
  • Flexible: Supports various SQL operations, including SELECT, INSERT, UPDATE, DELETE, and JOIN.
  • Transaction Management: Provides methods for starting, committing, and rolling back transactions.
  • Caching: Optionally caches query results for improved performance.
  • Set Operations: Supports INTERSECT, UNION, and EXCEPT set operations.

Contributing

If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages