Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/LionDatabase/Drivers/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,17 @@

/**
* Provides an interface to build SQL queries dynamically in PHP applications
* that interact with MySQL databases
* that interact with MySQL databases.
*
* Key Features:
*
* * Intuitive methods: Simple methods to build SQL queries programmatically
* * Intuitive methods: Simple methods to build SQL queries programmatically.
* * SQL Injection Prevention: Helps prevent SQL injection attacks by sanitizing
* data entered in queries
* data entered in queries.
* * Flexibility: Allows the construction of dynamic queries adapted to
* different application scenarios
* different application scenarios.
* * Optimization for MySQL: Designed specifically to work with MySQL,
* guaranteeing compatibility and optimization with this DBMS
*
* @package Lion\Database\Drivers
* guaranteeing compatibility and optimization with this DBMS.
*/
class MySQL extends Connection implements
AndInterface,
Expand Down
12 changes: 10 additions & 2 deletions src/LionDatabase/Drivers/Schema/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class MySQL extends Connection implements DatabaseConfigInterface, ExecuteInterf
/**
* {@inheritdoc}
*/
public static function execute(): stdClass
public static function execute(): int|stdClass
{
return parent::process(function (): stdClass {
return parent::process(function (): int|stdClass {
self::prepare(self::$sql);

if (!self::$stmt->execute()) {
Expand Down Expand Up @@ -261,10 +261,14 @@ public static function createStoredProcedure(string $storedProcedure, Closure $p
self::getKey(Driver::MYSQL, 'begin'),
]);

/** @var string $activeConnection */
$activeConnection = self::$activeConnection;

$begin(
DriverMySQL::run(self::$connections)
->isSchema()
->enableInsert(true)
->connection($activeConnection)
);

self::addQueryList([
Expand Down Expand Up @@ -319,10 +323,14 @@ public static function createView(string $view, Closure $viewBody): self
self::getKey(Driver::MYSQL, 'as')
]);

/** @var string $activeConnection */
$activeConnection = self::$activeConnection;

$viewBody(
DriverMySQL::run(self::$connections)
->isSchema()
->enableInsert(true)
->connection($activeConnection)
);

return new self();
Expand Down
4 changes: 1 addition & 3 deletions src/LionDatabase/Traits/RunInterfaceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public static function run(array $connections): self

self::$connections = $connections;

self::$activeConnection = empty(self::$activeConnection)
? self::$connections[Connection::CONNECTION_DEFAULT]
: self::$activeConnection;
self::$activeConnection = self::$connections[Connection::CONNECTION_DEFAULT];

$connectionsList = self::$connections[Connection::CONNECTION_CONNECTIONS];

Expand Down