Skip to content

Commit 942bb2c

Browse files
committed
SQL map update
1 parent e40f03a commit 942bb2c

6 files changed

Lines changed: 22 additions & 12 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

example/usage_loadDatabaseFiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
// Create your connection
14-
$_connection = new mysqli('localhost','root','','test_db');
14+
$_connection = new mysqli('localhost','root','','discite_remise');
1515

1616

1717
// Initiate DisciteDB Manager

src/DisciteDB/Database.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@
33

44
use DisciteDB\Config\Enums\TableUsage;
55
use DisciteDB\Core\DebugManager;
6-
use DisciteDB\Core\ExceptionsManager;
76
use DisciteDB\Core\KeysManager;
87
use DisciteDB\Core\LogsManager;
9-
use DisciteDB\Core\QueryManager;
108
use DisciteDB\Core\SecurityManager;
119
use DisciteDB\Core\TablesManager;
1210
use DisciteDB\Core\UsersManager;
13-
use DisciteDB\Exceptions\TableException;
14-
use DisciteDB\Keys\BaseKey;
1511
use DisciteDB\QueryHandler\QueryResult;
16-
use DisciteDB\Sql\Loading\Handler;
1712
use DisciteDB\Sql\Loading\HandlerDatabase;
1813
use DisciteDB\Sql\Loading\HandlerFile;
19-
use DisciteDB\Tables\BaseTable;
2014
use DisciteDB\Tables\TableInterface;
21-
use DisciteDB\Users\BaseUser;
2215
use mysqli;
2316

2417
/**
@@ -79,6 +72,12 @@ class Database
7972
*/
8073
protected DebugManager $debugManager;
8174

75+
76+
/**
77+
* @var ?array map of SQL file or from SQL Database.
78+
*/
79+
protected ?array $sqlMap;
80+
8281
/**
8382
* Database constructor.
8483
*
@@ -257,7 +256,7 @@ public function __get(string $name): QueryResult|TableInterface
257256
*/
258257
public function loadFromDatabase() : void
259258
{
260-
new HandlerDatabase($this->connection()->get(), $this);
259+
$this->sqlMap = (new HandlerDatabase($this->connection()->get(), $this))->getArray();
261260
}
262261

263262
/**
@@ -273,7 +272,7 @@ public function loadFromDatabase() : void
273272
*/
274273
public function loadFromFile(string $path, int $updatingTime) : void
275274
{
276-
new HandlerFile($path, $updatingTime, $this->connection()->get(), $this);
275+
$this->sqlMap = (new HandlerFile($path, $updatingTime, $this->connection()->get(), $this))->getArray();
277276
}
278277

279278

src/DisciteDB/Sql/Loading/HandlerDatabase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function __construct(mysqli $connection, Database $database)
3535

3636
}
3737

38+
public function getArray() : ?array
39+
{
40+
return $this->array;
41+
}
3842

3943
private function retrieveArray() : array
4044
{

src/DisciteDB/Sql/Loading/HandlerFile.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ public function __construct(string $path, int $updatingTime, mysqli $connection,
4949

5050
}
5151

52+
public function getArray() : ?array
53+
{
54+
return $this->array;
55+
}
56+
5257

53-
private function retrieveFile()
58+
private function retrieveFile() : void
5459
{
5560
if (file_exists($this->path))
5661
{

src/DisciteDB/Tables/TableInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace DisciteDB\Tables;
44

5+
use DisciteDB\Config\Enums\Operators;
6+
use DisciteDB\Config\Enums\QuerySort;
7+
use DisciteDB\Keys\BaseKey;
58
use DisciteDB\QueryHandler\QueryResult;
69

710
interface TableInterface
@@ -73,7 +76,6 @@ public function retrieve(string|int|array $uuid): QueryResult;
7376
* @return QueryResult
7477
*/
7578
public function keys(): QueryResult;
76-
7779
}
7880

7981
?>

0 commit comments

Comments
 (0)