Skip to content

Commit 4f40fbf

Browse files
committed
V1.0.1
1 parent 7335734 commit 4f40fbf

File tree

11 files changed

+217
-134
lines changed

11 files changed

+217
-134
lines changed

builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SOFTWARE.
2323
*/
2424

2525

26-
var version = "1.0.0";
26+
var version = "1.0.1";
2727

2828
var today = new Date();
2929
var dd = today.getDate();

dist/SuperSQL.php

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Author: Andrews54757
44
License: MIT (https://github.com/ThreeLetters/SuperSQL/blob/master/LICENSE)
55
Source: https://github.com/ThreeLetters/SQL-Library
6-
Build: v1.0.0
6+
Build: v1.0.1
77
Built on: 09/08/2017
88
*/
99

@@ -259,7 +259,7 @@ public static function DELETE($table, $where)
259259
// lib/parser/Advanced.php
260260
class AdvParser
261261
{
262-
private static function getArg(&$str)
262+
static function getArg(&$str)
263263
{
264264
if (substr($str, 0, 1) == "[" && substr($str, 3, 1) == "]") {
265265
$out = substr($str, 1, 2);
@@ -269,7 +269,7 @@ private static function getArg(&$str)
269269
return false;
270270
}
271271
}
272-
private static function append(&$args, $val, $index, $values)
272+
static function append(&$args, $val, $index, $values)
273273
{
274274
if (gettype($val) == "array" && $values[$index][2] < 5) {
275275
$len = count($val);
@@ -280,7 +280,7 @@ private static function append(&$args, $val, $index, $values)
280280
}
281281
}
282282
}
283-
private static function append2(&$insert, $indexes, $dt, $values)
283+
static function append2(&$insert, $indexes, $dt, $values)
284284
{
285285
function stripArgs(&$key)
286286
{
@@ -356,7 +356,7 @@ function recurse(&$holder, $val, $indexes, $par, $values)
356356
recurse($insert[$key], $val, $indexes, "", $values);
357357
}
358358
}
359-
private static function quote($str)
359+
static function quote($str)
360360
{
361361
$str = explode(".", $str);
362362
$out = "";
@@ -367,7 +367,7 @@ private static function quote($str)
367367
}
368368
return $out;
369369
}
370-
private static function table($table)
370+
static function table($table)
371371
{
372372
if (gettype($table) == "array") {
373373
$sql = "";
@@ -384,7 +384,7 @@ private static function table($table)
384384
return self::quote($table);
385385
}
386386
}
387-
private static function value($type, $value, &$typeString)
387+
static function value($type, $value, &$typeString)
388388
{
389389
$var = strtolower($type);
390390
if (!$var)
@@ -432,7 +432,7 @@ private static function value($type, $value, &$typeString)
432432
$dtype
433433
);
434434
}
435-
private static function getType(&$str)
435+
static function getType(&$str)
436436
{
437437
if (substr($str, -1) == "]") {
438438
$start = strrpos($str, "[");
@@ -445,14 +445,14 @@ private static function getType(&$str)
445445
} else
446446
return "";
447447
}
448-
private static function rmComments($str) {
448+
static function rmComments($str) {
449449
$i = strpos($str,"#");
450450
if ($i !== false) {
451451
$str = substr($str,0,$i);
452452
}
453453
return trim($str);
454454
}
455-
private static function conditions($dt, &$values = false, &$map = false, &$typeString = "", &$index = 0)
455+
static function conditions($dt, &$values = false, &$map = false, &$typeString = "", &$index = 0)
456456
{
457457
$build = function(&$build, $dt, &$map, &$index, &$values, &$typeString, $join = " AND ", $operator = " = ", $parent = "")
458458
{
@@ -566,6 +566,37 @@ private static function conditions($dt, &$values = false, &$map = false, &$typeS
566566
};
567567
return $build($build, $dt, $map, $index, $values, $typeString);
568568
}
569+
static function JOIN($join, &$sql) {
570+
foreach ($join as $key => $val) {
571+
if (substr($key, 0, 1) === "#") {
572+
$raw = true;
573+
$key = substr($key, 1);
574+
} else {
575+
$raw = false;
576+
}
577+
$arg = self::getArg($key);
578+
switch ($arg) {
579+
case "<<":
580+
$sql .= " RIGHT JOIN ";
581+
break;
582+
case ">>":
583+
$sql .= " LEFT JOIN ";
584+
break;
585+
case "<>":
586+
$sql .= " FULL JOIN ";
587+
break;
588+
default:
589+
$sql .= " JOIN ";
590+
break;
591+
}
592+
$sql .= self::quote($key) . " ON ";
593+
if ($raw) {
594+
$sql .= "val";
595+
} else {
596+
$sql .= self::conditions($val);
597+
}
598+
}
599+
}
569600
static function SELECT($table, $columns, $where, $join, $limit)
570601
{
571602
$sql = "SELECT ";
@@ -622,35 +653,7 @@ static function SELECT($table, $columns, $where, $join, $limit)
622653
}
623654
$sql .= " FROM " . self::table($table);
624655
if ($join) {
625-
foreach ($join as $key => $val) {
626-
if (substr($key, 0, 1) === "#") {
627-
$raw = true;
628-
$key = substr($key, 1);
629-
} else {
630-
$raw = false;
631-
}
632-
$arg = self::getArg($key);
633-
switch ($arg) {
634-
case "<<":
635-
$sql .= " RIGHT JOIN ";
636-
break;
637-
case ">>":
638-
$sql .= " LEFT JOIN ";
639-
break;
640-
case "<>":
641-
$sql .= " FULL JOIN ";
642-
break;
643-
default:
644-
$sql .= " JOIN ";
645-
break;
646-
}
647-
$sql .= self::quote($key) . " ON ";
648-
if ($raw) {
649-
$sql .= "val";
650-
} else {
651-
$sql .= self::conditions($val);
652-
}
653-
}
656+
self::JOIN($join,$sql);
654657
}
655658
$typeString = "";
656659
if (count($where) != 0) {

dist/SuperSQL_advanced.php

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Author: Andrews54757
44
License: MIT (https://github.com/ThreeLetters/SuperSQL/blob/master/LICENSE)
55
Source: https://github.com/ThreeLetters/SQL-Library
6-
Build: v1.0.0
6+
Build: v1.0.1
77
Built on: 09/08/2017
88
*/
99

@@ -165,7 +165,7 @@ function clearCache()
165165
// lib/parser/Advanced.php
166166
class AdvParser
167167
{
168-
private static function getArg(&$str)
168+
static function getArg(&$str)
169169
{
170170
if (substr($str, 0, 1) == "[" && substr($str, 3, 1) == "]") {
171171
$out = substr($str, 1, 2);
@@ -175,7 +175,7 @@ private static function getArg(&$str)
175175
return false;
176176
}
177177
}
178-
private static function append(&$args, $val, $index, $values)
178+
static function append(&$args, $val, $index, $values)
179179
{
180180
if (gettype($val) == "array" && $values[$index][2] < 5) {
181181
$len = count($val);
@@ -186,7 +186,7 @@ private static function append(&$args, $val, $index, $values)
186186
}
187187
}
188188
}
189-
private static function append2(&$insert, $indexes, $dt, $values)
189+
static function append2(&$insert, $indexes, $dt, $values)
190190
{
191191
function stripArgs(&$key)
192192
{
@@ -262,7 +262,7 @@ function recurse(&$holder, $val, $indexes, $par, $values)
262262
recurse($insert[$key], $val, $indexes, "", $values);
263263
}
264264
}
265-
private static function quote($str)
265+
static function quote($str)
266266
{
267267
$str = explode(".", $str);
268268
$out = "";
@@ -273,7 +273,7 @@ private static function quote($str)
273273
}
274274
return $out;
275275
}
276-
private static function table($table)
276+
static function table($table)
277277
{
278278
if (gettype($table) == "array") {
279279
$sql = "";
@@ -290,7 +290,7 @@ private static function table($table)
290290
return self::quote($table);
291291
}
292292
}
293-
private static function value($type, $value, &$typeString)
293+
static function value($type, $value, &$typeString)
294294
{
295295
$var = strtolower($type);
296296
if (!$var)
@@ -338,7 +338,7 @@ private static function value($type, $value, &$typeString)
338338
$dtype
339339
);
340340
}
341-
private static function getType(&$str)
341+
static function getType(&$str)
342342
{
343343
if (substr($str, -1) == "]") {
344344
$start = strrpos($str, "[");
@@ -351,14 +351,14 @@ private static function getType(&$str)
351351
} else
352352
return "";
353353
}
354-
private static function rmComments($str) {
354+
static function rmComments($str) {
355355
$i = strpos($str,"#");
356356
if ($i !== false) {
357357
$str = substr($str,0,$i);
358358
}
359359
return trim($str);
360360
}
361-
private static function conditions($dt, &$values = false, &$map = false, &$typeString = "", &$index = 0)
361+
static function conditions($dt, &$values = false, &$map = false, &$typeString = "", &$index = 0)
362362
{
363363
$build = function(&$build, $dt, &$map, &$index, &$values, &$typeString, $join = " AND ", $operator = " = ", $parent = "")
364364
{
@@ -472,6 +472,37 @@ private static function conditions($dt, &$values = false, &$map = false, &$typeS
472472
};
473473
return $build($build, $dt, $map, $index, $values, $typeString);
474474
}
475+
static function JOIN($join, &$sql) {
476+
foreach ($join as $key => $val) {
477+
if (substr($key, 0, 1) === "#") {
478+
$raw = true;
479+
$key = substr($key, 1);
480+
} else {
481+
$raw = false;
482+
}
483+
$arg = self::getArg($key);
484+
switch ($arg) {
485+
case "<<":
486+
$sql .= " RIGHT JOIN ";
487+
break;
488+
case ">>":
489+
$sql .= " LEFT JOIN ";
490+
break;
491+
case "<>":
492+
$sql .= " FULL JOIN ";
493+
break;
494+
default:
495+
$sql .= " JOIN ";
496+
break;
497+
}
498+
$sql .= self::quote($key) . " ON ";
499+
if ($raw) {
500+
$sql .= "val";
501+
} else {
502+
$sql .= self::conditions($val);
503+
}
504+
}
505+
}
475506
static function SELECT($table, $columns, $where, $join, $limit)
476507
{
477508
$sql = "SELECT ";
@@ -528,35 +559,7 @@ static function SELECT($table, $columns, $where, $join, $limit)
528559
}
529560
$sql .= " FROM " . self::table($table);
530561
if ($join) {
531-
foreach ($join as $key => $val) {
532-
if (substr($key, 0, 1) === "#") {
533-
$raw = true;
534-
$key = substr($key, 1);
535-
} else {
536-
$raw = false;
537-
}
538-
$arg = self::getArg($key);
539-
switch ($arg) {
540-
case "<<":
541-
$sql .= " RIGHT JOIN ";
542-
break;
543-
case ">>":
544-
$sql .= " LEFT JOIN ";
545-
break;
546-
case "<>":
547-
$sql .= " FULL JOIN ";
548-
break;
549-
default:
550-
$sql .= " JOIN ";
551-
break;
552-
}
553-
$sql .= self::quote($key) . " ON ";
554-
if ($raw) {
555-
$sql .= "val";
556-
} else {
557-
$sql .= self::conditions($val);
558-
}
559-
}
562+
self::JOIN($join,$sql);
560563
}
561564
$typeString = "";
562565
if (count($where) != 0) {

0 commit comments

Comments
 (0)