Skip to content

Commit 6e5ef25

Browse files
authored
v1.0.5
Simple api is now gone. Some restructuring, namespaces, etc...
2 parents fd3f710 + 8843b94 commit 6e5ef25

17 files changed

+542
-2303
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ SlickInject and Medoo on steroids - The most advanced and lightweight library of
1111
1. Very small - 24.2KB one file (Unminified, `dist/SuperSQL.php`. Minified version: 10.2KB)
1212
2. Simple and easy - Very easy to lean. We also provide a simple and advanced API
1313
3. Compatability - Supports major SQL databases
14-
4. Customisability - We offer multiple files for your needs
15-
5. Efficiency - This module was built with speed in mind.
16-
6. Complexity - This module allows you to make all kinds of complex queries
17-
7. Security - This module prevents SQL injections.
18-
8. Availability - This module is FREE. Licensed under the MIT license.
14+
4. Efficiency - This module was built with speed in mind.
15+
5. Complexity - This module allows you to make all kinds of complex queries
16+
6. Security - This module prevents SQL injections.
17+
7. Availability - This module is FREE. Licensed under the MIT license.
1918

2019
## Notes
2120
#### Missing features.
@@ -32,6 +31,8 @@ You may either
3231
new SuperSQL($dsn,$user,$pass);
3332
```
3433
```php
34+
use SuperSQL\SuperSQL;
35+
3536
// MySql setup
3637
$host = "localhost";
3738
$db = "test";
@@ -41,6 +42,19 @@ $pass = "1234";
4142
$dsn = "mysql:host=$host;port=3306;dbname=$db;charset=utf8";
4243
$SuperSQL = new SuperSQL($dsn,$user,$pass);
4344
```
45+
46+
```php
47+
use SuperSQL\SQLHelper;
48+
49+
// MySql setup
50+
$host = "localhost";
51+
$db = "test";
52+
$user = "root";
53+
$pass = "1234";
54+
55+
$SuperSQL = SQLHelper::connect($host, $db, $user,$pass);
56+
```
57+
4458
## Build
4559
To build this library, do
4660

@@ -62,7 +76,6 @@ Not much - they are basically the equivalant - However, SuperSQL is slightly mor
6276

6377
* Response class - SuperSQL has a response class to access crucial information, such as errors
6478
* Helper - SuperSQL comes with a helper class, with helper functions, while meedoo has it built right in.
65-
* Simple API - SuperSQL comes with a simple api for simple queries to increase performance. No need to go overkill for something as simple as `SELECT * FROM table`
6679
* Smaller & lightweight - SuperSQL is smaller than medoo
6780
* Development - SuperSQL's code is well structured and it is commented - so you can understand it more
6881
* SuperSQL is faster - Using xdebug, we found that superSQL is faster than medoo. (x1000,6%)

builder.js

Lines changed: 65 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SOFTWARE.
2323
*/
2424

2525

26-
var version = "1.0.3";
26+
var version = "1.0.5";
2727

2828
var today = new Date();
2929
var dd = today.getDate();
@@ -261,21 +261,18 @@ function minify(str,options) {
261261

262262
var fs = require("fs");
263263

264-
var simple = fs.readFileSync(__dirname + "/lib/parser/Simple.php", "utf8");
264+
var adv = fs.readFileSync(__dirname + "/lib/parser.php", "utf8");
265265

266-
var adv = fs.readFileSync(__dirname + "/lib/parser/Advanced.php", "utf8");
267-
268-
var connector = fs.readFileSync(__dirname + "/lib/connector/index.php", "utf8");
266+
var connector = fs.readFileSync(__dirname + "/lib/connector.php", "utf8");
269267

270268
var main = fs.readFileSync(__dirname + "/index.php", "utf8");
271269

272-
var helper = fs.readFileSync(__dirname + "/lib/helper/index.php", "utf8");
270+
var helper = fs.readFileSync(__dirname + "/lib/helper.php", "utf8");
273271

274272
var startstr = "// BUILD BETWEEN";
275273

276274

277275

278-
simple = removeComments(simple.split(startstr)[1]);
279276
adv = removeComments(adv.split(startstr)[1]);
280277
connector = removeComments(connector.split(startstr)[1]);
281278
var index = main.split(startstr)[1];
@@ -289,103 +286,82 @@ var out = `<?php\n\
289286
Source: https://github.com/ThreeLetters/SQL-Library\n\
290287
Build: v${version}\n\
291288
Built on: ${date}\n\
292-
*/\n\n`;
289+
*/\n\
290+
\n\
291+
namespace SuperSQL;\n\
292+
\n`;
293293

294-
var complete = `// lib/connector/index.php\
294+
var complete = `// lib/connector.php\
295295
${connector}\n\
296-
// lib/parser/Simple.php\
297-
${simple}\n\
298-
// lib/parser/Advanced.php\
296+
// lib/parser.php\
299297
${adv}\n\
300298
// index.php\
301299
${main}\
302300
?>`;
303301

304-
var completeMin = `// lib/connector/index.php\n\
302+
var completeMin = `// lib/connector.php\n\
305303
${minify(connector)}\n\
306-
// lib/parser/Simple.php\n\
307-
${minify(simple)}\n\
308-
// lib/parser/Advanced.php\n\
304+
// lib/parser.php\n\
309305
${minify(adv)}\n\
310306
// index.php\n\
311307
${minify(main)}\n\
312308
?>`;
313309

314-
var smain = index.split("// BUILD ADVANCED BETWEEN");
315-
smain = (smain[0] + smain[2]);
316-
smain = removeComments(smain);
317-
var simpleOnly = `// lib/connector/index.php\
318-
${connector}\n\
319-
// lib/parser/Simple.php\
320-
${simple}\n\
321-
// index.php\
322-
${smain}\
323-
?>`;
324-
var simpleOnlyMin = `// lib/connector/index.php\n\
325-
${minify(connector)}\n\
326-
// lib/parser/Simple.php\n\
327-
${minify(simple)}\n\
328-
// index.php\n\
329-
${minify(smain)}\n\
330-
?>`;
331-
332-
var amain = index.split("// BUILD SIMPLE BETWEEN");
333-
amain = (amain[0] + amain[2]);
334-
amain = removeComments(amain);
335-
var advancedOnly = `// lib/connector/index.php\
336-
${connector}\n\
337-
// lib/parser/Advanced.php\
338-
${adv}\n\
339-
// index.php\
340-
${amain}\
341-
?>`;
342310

343-
var advancedOnlyMin = `// lib/connector/index.php\n\
344-
${minify(connector)}\n\
345-
// lib/parser/Advanced.php\n\
346-
${minify(adv)}\n\
347-
// index.php\n\
348-
${minify(amain)}\n\
349-
?>`;
350311

351312
var a = out + complete,
352313
b = out + completeMin,
353-
c = out + simpleOnly,
354-
d = out + simpleOnlyMin,
355-
e = out + advancedOnly,
356-
f = out + advancedOnlyMin,
357-
g = out + helper,
358-
h = out + minify(helper) + "\n?>";
359-
360-
361-
fs.writeFileSync(__dirname + "/dist/SuperSQL.php", a);
362-
fs.writeFileSync(__dirname + "/dist/SuperSQL_min.php", b);
363-
364-
365-
fs.writeFileSync(__dirname + "/dist/SuperSQL_simple.php", c);
366-
fs.writeFileSync(__dirname + "/dist/SuperSQL_simple_min.php", d);
367-
368-
369-
fs.writeFileSync(__dirname + "/dist/SuperSQL_advanced.php", e);
370-
fs.writeFileSync(__dirname + "/dist/SuperSQL_advanced_min.php", f);
371-
372-
373-
fs.writeFileSync(__dirname + "/dist/SuperSQL_helper.php", g);
374-
fs.writeFileSync(__dirname + "/dist/SuperSQL_helper_min.php", h);
375-
376-
377-
console.log("Compiled files into dist. Stats:");
378-
379-
console.log("OUTPUT");
380-
381-
console.log(`SuperSQL: ~${a.length} Lines: ~${a.split("\n").length} - Minified: ~${b.length} Lines: ~${b.split("\n").length}`);
382-
console.log(`Simple: ~${c.length} Lines: ~${c.split("\n").length} - Minified: ~${d.length} Lines: ~${d.split("\n").length}`);
383-
console.log(`Advanced: ~${e.length} Lines: ~${e.split("\n").length} - Minified: ~${f.length} Lines: ~${f.split("\n").length}`);
384-
console.log(`Helper: ~${g.length} Lines: ~${g.split("\n").length} - Minified: ~${h.length} Lines: ~${h.split("\n").length}`);
385-
386-
console.log("FILES");
314+
c = out + helper,
315+
d = out + minify(helper) + "\n?>";
316+
317+
var dir1 = __dirname + "/dist/SuperSQL.php",
318+
dir2 = __dirname + "/dist/SuperSQL_min.php",
319+
dir3 = __dirname + "/dist/SuperSQL_helper.php",
320+
dir4 = __dirname + "/dist/SuperSQL_helper_min.php";
321+
322+
fs.writeFileSync(dir1, a);
323+
fs.writeFileSync(dir2, b);
324+
325+
326+
fs.writeFileSync(dir3, c);
327+
fs.writeFileSync(dir4, d);
328+
329+
var readme = "## Files\n\
330+
\n\
331+
* `SuperSQL.php` - Main file\n\
332+
* `SuperSQL_min.php`\n\
333+
* `SuperSQL_helper.php` - Helper functions\n\
334+
* `SuperSQL_helper_min.php`\n\
335+
\n\
336+
### Sizes\n\
337+
\n";
338+
var crypto = require('crypto');
339+
function size(filename) {
340+
const stats = fs.statSync(filename);
341+
const fileSizeInBytes = stats.size
342+
return Math.round(fileSizeInBytes / 100) / 10;
343+
}
344+
function hash(data) {
387345

388-
console.log(`Index ${index.length} Lines: ~${index.split("\n").length}`);
389-
console.log(`Connector ${connector.length} Lines: ~${connector.split("\n").length}`);
390-
console.log(`SimpleParser ${simple.length} Lines: ~${simple.split("\n").length}`);
391-
console.log(`AdvancedParser ${adv.length} Lines: ~${adv.split("\n").length}`);
346+
return crypto.createHash('md5').update(data).digest("hex");
347+
}
348+
var sizes = `\
349+
* \`SuperSQL.php\` - ${a.length} Chars (${size(dir1)} MB)\n\
350+
* \`SuperSQL_min.php\` - ${b.length} Chars (${size(dir2)} MB)\n\
351+
* \`SuperSQL_helper.php\` - ${c.length} Chars (${size(dir3)} MB)\n\
352+
* \`SuperSQL_helper_min.php\` - ${d.length} Chars (${size(dir4)} MB)\n\
353+
\n\
354+
## Hashes\n\
355+
\n\
356+
\`\`\`\n\
357+
* SuperSQL.php - ${hash(a)}\n\
358+
* SuperSQL_min.php - ${hash(b)}\n\
359+
* SuperSQL_helper.php - ${hash(c)}\n\
360+
* SuperSQL_helper_min.php - ${hash(d)}\n\
361+
\`\`\`\n`;
362+
363+
364+
readme += sizes;
365+
366+
fs.writeFileSync(__dirname + "/dist/README.md",readme);
367+
console.log("Compiled files into dist");

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "threeletters/supersql",
33
"description": "SlickInject and Medoo on steroids - The most advanced and lightweight library of its kind.",
4-
"version":"1.0.3",
4+
"version":"1.0.5",
55
"type": "framework",
66
"keywords": ["SQL","database","small","lightweight","advanced","MySQL"],
77
"homepage": "https://threeletters.github.io/SuperSQL/",

dist/README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
## Files
22

33
* `SuperSQL.php` - Main file
4-
* `SuperSQL_simple.php` - SuperSQL with only simple API
5-
* `SuperSQL_advanced.php` - SuperSQL with only advanced API
4+
* `SuperSQL_min.php`
65
* `SuperSQL_helper.php` - Helper functions
6+
* `SuperSQL_helper_min.php`
77

8-
### Minified:
9-
10-
* `SuperSQL_min.php` - Main file
11-
* `SuperSQL_simple_min.php` - SuperSQL with only simple API
12-
* `SuperSQL_advanced_min.php` - SuperSQL with only advanced API
13-
* `SuperSQL_helper_min.php` - Helper functions
8+
### Sizes
149

10+
* `SuperSQL.php` - 26923 Chars (26.9 MB)
11+
* `SuperSQL_min.php` - 11478 Chars (11.5 MB)
12+
* `SuperSQL_helper.php` - 10075 Chars (10.1 MB)
13+
* `SuperSQL_helper_min.php` - 4937 Chars (4.9 MB)
1514

16-
### Sizes
15+
## Hashes
1716

1817
```
19-
SuperSQL: ~24788 Lines: ~795 - Minified: ~10396 Lines: ~18
20-
Simple: ~7365 Lines: ~286 - Minified: ~3770 Lines: ~16
21-
Advanced: ~21645 Lines: ~681 - Minified: ~8936 Lines: ~15
22-
Helper: ~4910 Lines: ~148 - Minified: ~2319 Lines: ~11
18+
* SuperSQL.php - 2333e36c28c2936f435df070730d0dc6
19+
* SuperSQL_min.php - c510780f1d7d5f5c2bc4053a14196a8c
20+
* SuperSQL_helper.php - 0b0dbc5e64732a79c0bd313f53d5c1b7
21+
* SuperSQL_helper_min.php - fe467c9d097573da7cd5a3db6cbd0936
2322
```

0 commit comments

Comments
 (0)