Skip to content

Commit 9d0aa22

Browse files
committed
v1.0.6
1 parent 5164275 commit 9d0aa22

9 files changed

+141
-47
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ $pass = "1234";
5454

5555
$SuperSQL = SQLHelper::connect($host, $db, $user,$pass);
5656
```
57+
```php
58+
$result = $SuperSQL->select("test",[],[
59+
"condition" => 12345,
60+
"[||][&&]" => [
61+
"something" => "value",
62+
"anotherthing" => "val"
63+
]
64+
]); // SELECT * FROM `test` WHERE `condition` = 12345 OR (`something` = 'value' AND `anotherthing` = 'val')
65+
66+
if (!$result->error()) {
67+
foreach ($result as $val) { // NOTE, $result is NOT an array
68+
echo $val;
69+
}
70+
} else {
71+
echo json_encode($result->error());
72+
}
73+
```
5774

5875
## Build
5976
To build this library, do

builder.js

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

2525

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

2828
var today = new Date();
2929
var dd = today.getDate();
@@ -103,17 +103,17 @@ function removeComments(str) {
103103
}
104104

105105
// Minifier -> https://github.com/ThreeLetters/PHP-Minify-js
106-
function minify(str,options) {
106+
function minify(str, options) {
107107
if (!options) options = {};
108108
str = removeComments(str);
109109
var varReplace = options.varReplace === undefined ? true : options.varReplace;
110110
var extreme = options.extremeMinify === undefined ? true : options.extremeMinify;
111111
var removeLine = options.removeLine === undefined ? true : options.removeLine;
112-
112+
113113
if (removeLine) {
114-
str = str.replace(/\n/g, "").replace(/\t/g,"").split("");
114+
str = str.replace(/\n/g, "").replace(/\t/g, "").split("");
115115
} else {
116-
str = str.split("");
116+
str = str.split("");
117117
}
118118
var len = str.length;
119119
var out = [];
@@ -166,13 +166,13 @@ function minify(str,options) {
166166
function includes(char) {
167167

168168
var dt = [";", "{", "}", ",", "(", ")", "[", "]", "=", ">", "<", "."];
169-
if (extreme) dt.push("&","|","+","-","*","/");
169+
if (extreme) dt.push("&", "|", "+", "-", "*", "/");
170170
return dt.indexOf(char) != -1;
171171
}
172172

173173
function includes2(char) {
174174
var dt = ["=", "{", "(", "}", ")", "]", ">", "<", "!", "."];
175-
if (extreme) dt.push("$","&","|","+","-","*","/");
175+
if (extreme) dt.push("$", "&", "|", "+", "-", "*", "/");
176176
return dt.indexOf(char) != -1;
177177
}
178178

@@ -335,15 +335,17 @@ var readme = "## Files\n\
335335
\n\
336336
### Sizes\n\
337337
\n";
338-
var crypto = require('crypto');
338+
var crypto = require('crypto');
339+
339340
function size(filename) {
340341
const stats = fs.statSync(filename);
341342
const fileSizeInBytes = stats.size
342343
return Math.round(fileSizeInBytes / 100) / 10;
343344
}
345+
344346
function hash(data) {
345347

346-
return crypto.createHash('md5').update(data).digest("hex");
348+
return crypto.createHash('md5').update(data).digest("hex");
347349
}
348350
var sizes = `\
349351
* \`SuperSQL.php\` - ${a.length} Chars (${size(dir1)} MB)\n\
@@ -363,5 +365,5 @@ var sizes = `\
363365

364366
readme += sizes;
365367

366-
fs.writeFileSync(__dirname + "/dist/README.md",readme);
368+
fs.writeFileSync(__dirname + "/dist/README.md", readme);
367369
console.log("Compiled files into dist");

dist/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
### Sizes
99

10-
* `SuperSQL.php` - 28177 Chars (28.2 MB)
11-
* `SuperSQL_min.php` - 12010 Chars (12 MB)
10+
* `SuperSQL.php` - 28998 Chars (29 MB)
11+
* `SuperSQL_min.php` - 12509 Chars (12.5 MB)
1212
* `SuperSQL_helper.php` - 10075 Chars (10.1 MB)
1313
* `SuperSQL_helper_min.php` - 4937 Chars (4.9 MB)
1414

1515
## Hashes
1616

1717
```
18-
* SuperSQL.php - 6ba6ece6540d92ee4b2e22de33935a40
19-
* SuperSQL_min.php - e41a963acf08e85844d3947970fec48c
20-
* SuperSQL_helper.php - ba92744abaeb9751ac5803329a9dd499
21-
* SuperSQL_helper_min.php - c826a781c51fce3b781f0cf96ddeddc8
18+
* SuperSQL.php - 48729b380ad8c84c4575b61b86d46669
19+
* SuperSQL_min.php - 9e9379786b7038cfb113e7c10e795dc5
20+
* SuperSQL_helper.php - c12e9205da2055555506aea6ef714296
21+
* SuperSQL_helper_min.php - 236c638ba7a4359b53e1325324987c27
2222
```

dist/SuperSQL.php

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
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.5
7-
Built on: 25/08/2017
6+
Build: v1.0.6
7+
Built on: 27/08/2017
88
*/
99

1010
namespace SuperSQL;
1111

1212
// lib/connector.php
13-
class Response
13+
class Response implements \ArrayAccess, \Iterator
1414
{
1515
public $result;
1616
public $affected;
@@ -74,7 +74,7 @@ private function fetchNextRow()
7474
}
7575
private function fetchAll()
7676
{
77-
while ($row = $this->fetchNextRow()) {
77+
while ($this->fetchNextRow()) {
7878
}
7979
}
8080
function map(&$row, &$outtypes)
@@ -119,6 +119,30 @@ function countRows()
119119
{
120120
return count($this->result);
121121
}
122+
function offsetSet($offset, $value)
123+
{
124+
}
125+
function offsetExists($offset)
126+
{
127+
return $this->offsetGet($offset) === null ? false : true;
128+
}
129+
function offsetUnset($offset)
130+
{
131+
}
132+
function offsetGet($offset)
133+
{
134+
if (is_int($offset)) {
135+
if (isset($this->result[$offset])) {
136+
return $this->result[$offset];
137+
} else if (!$this->complete) {
138+
while ($this->fetchNextRow()) {
139+
if (isset($this->result[$offset]))
140+
return $this->result[$offset];
141+
}
142+
}
143+
}
144+
return null;
145+
}
122146
function next()
123147
{
124148
if (isset($this->result[$this->ind])) {
@@ -131,10 +155,22 @@ function next()
131155
return false;
132156
}
133157
}
134-
function reset()
158+
function rewind()
135159
{
136160
$this->ind = 0;
137161
}
162+
function current()
163+
{
164+
return $this->result[$this->ind];
165+
}
166+
function key()
167+
{
168+
return $this->ind;
169+
}
170+
function valid()
171+
{
172+
return $this->offsetExists($this->ind);
173+
}
138174
}
139175
class Connector
140176
{
@@ -465,16 +501,17 @@ static function conditions($dt, &$values = false, &$map = false, &$index = 0)
465501
if (!$raw)
466502
$column = self::quote($column);
467503
if ($arr) {
504+
$sql .= '(';
468505
if ($useBind) {
469-
$sql .= '(' . $build($build, $val, $map, $index, $values, $newJoin, $newOperator, $parent . '/' . $key) . ')';
506+
$sql .= $build($build, $val, $map, $index, $values, $newJoin, $newOperator, $parent . '/' . $key);
470507
} else {
471508
if ($map !== false && !$raw) {
472509
$map[$key] = $index;
473510
$map[$key . '#' . $parent] = $index++;
474511
}
475512
if ($between) {
476513
$index += 2;
477-
$sql .= '(' . $column . ($arg === '<>' ? 'NOT' : '') . ' BETWEEN ';
514+
$sql .= $column . ($arg === '<>' ? 'NOT' : '') . ' BETWEEN ';
478515
if ($raw) {
479516
$sql .= $val[0] . ' AND ' . $val[1];
480517
} else if ($values !== false) {
@@ -484,9 +521,7 @@ static function conditions($dt, &$values = false, &$map = false, &$index = 0)
484521
} else {
485522
$sql .= self::escape($val[0]) . ' AND ' . self::escape($val[1]);
486523
}
487-
$sql .= ')';
488524
} else {
489-
$sql .= '(';
490525
foreach ($val as $k => &$v) {
491526
if ($k !== 0)
492527
$sql .= $newJoin;
@@ -501,8 +536,8 @@ static function conditions($dt, &$values = false, &$map = false, &$index = 0)
501536
$sql .= self::escape($v);
502537
}
503538
}
504-
$sql .= ')';
505539
}
540+
$sql .= ')';
506541
}
507542
} else {
508543
$sql .= $column . $newOperator;

dist/SuperSQL_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
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.5
7-
Built on: 25/08/2017
6+
Build: v1.0.6
7+
Built on: 27/08/2017
88
*/
99

1010
namespace SuperSQL;

dist/SuperSQL_helper_min.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
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.5
7-
Built on: 25/08/2017
6+
Build: v1.0.6
7+
Built on: 27/08/2017
88
*/
99

1010
namespace SuperSQL;

0 commit comments

Comments
 (0)