WRITE SECURE SQL DIRECTLY IN JAVASCRIPT

One function. Multiple modes. Infinite possibilities!

Sonic SQL is a powerful function allowing you to write secure SQL in both PHP and JavaScript, and enabling you to protect your database from SQL injection—without the need for repetitive code.

							

Tired of Writing Repetitive SQL?

Writing secure SQL can often feel like a chore, leading to bloated code that not only wastes a developer's time but can also increase the risk of errors.

But with Sonic SQL, you can:

Protect against SQL injection
Bind parameters automatically
Use smart output modes like csv and json
Write queries in PHP or JavaScript

All in one line of code!

The normal way to write a perpared SQL statement

Getting Started with Sonic SQL

Once you've downloaded SQL.zip, extract the contents and move or upload them to whichever location you're working in. The files you need are ssql.php, ssql.js, and connect.php

Connect to your database – This is your default mysqli connection in connect.php.

$server = "localhost";

$username = " ";

$password = " ";

$database = " db_name";

Include or Require – Simply include or require ssql.php to write fast, secure queries in php

require "path/to/ssql.php";

Script – Call ssql.js to write fast, secure queries in JavaScript

<script src="path/to/ssql.js"></script>

$connect – An optional parameter that connects to your database and falls back to your default connection in ssql.php if not included

ssql($connect, "SELECT * FROM users WHERE name LIKE ?", ["J%"], "json");

Query – A standard MYSQL query where you must replace all values with ?

ssql("SELECT * FROM users WHERE name LIKE ?", ["J%"], "json");

Values – Enter your values in order and in square brackets [ ] separated by commas, with strings in quotations.

ssql("SELECT * FROM users WHERE age > ? AND name LIKE ?", [30, "J%"], "json");

- Or -

$values = [30, "J%"];

ssql("SELECT * FROM users WHERE age > ? AND name LIKE ?", $values, "json");

Format – This tells Sonic SQL how you want to return the data View Modes

ssql("SELECT * FROM users WHERE name LIKE ?", "J%", "json");

Download & Installation

  1. Download Sonic SQL and extract the zip file.
  2. Move "SonicSQL" to the path or folder you're working in.
  3. In PHP: Include or require ssql.php in your file.
  4. In JS: Call ssql.js in script tags.