-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaca370
commit 0582bee
Showing
21 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
@@ -59,6 +59,8 @@ class Database extends QueryBuilder | |
'deletable' => true, | ||
'updatable' => true, | ||
'return' => null, | ||
'debug' => false, | ||
'log' => null, | ||
]; | ||
|
||
private Result $_last; | ||
|
@@ -354,9 +356,13 @@ final public function query(string $sqlQuery, array $parameters = []): Result | |
} | ||
} catch (\Exception $e) { | ||
$message = $e->getMessage(); | ||
if(($this->_credentials['debug'] ?? false) === TRUE){ | ||
$message .= ' SQL : ' | ||
. (empty($parameters) ? $sqlQuery : \strtr($sqlQuery, $parameters)); | ||
$sqlMessage = 'SQL : ' | ||
. (empty($parameters) ? $sqlQuery : strtr($sqlQuery, $parameters)); | ||
if(!empty($this->_credentials['log'])){ | ||
$this->_logCreate($message . ' ' . $sqlMessage); | ||
} | ||
if($this->_credentials['debug'] === TRUE){ | ||
$message .= $message . ' ' . $sqlMessage; | ||
} | ||
throw new SQLQueryExecuteException($e->getMessage(), (int)$e->getCode()); | ||
} | ||
|
@@ -801,6 +807,34 @@ public function _deleteQuery(): string | |
. $this->_limitQuery(); | ||
} | ||
|
||
protected function _logCreate(string $message): void | ||
{ | ||
if(empty($this->_credentials['log'])){ | ||
return; | ||
} | ||
if(\is_callable($this->_credentials['log'])){ | ||
\call_user_func_array($this->_credentials['log'], [$message]); | ||
return; | ||
} | ||
if(\is_string($this->_credentials['log'])){ | ||
$path = \strtr($this->_credentials['log'], [ | ||
'{timestamp}' => \time(), | ||
'{date}' => \date("Y-m-d"), | ||
'{year}' => \date("Y"), | ||
'{month}' => \date("m"), | ||
'{day}' => \date("d"), | ||
'{hour}' => \date("H"), | ||
'{minute}' => \date("i"), | ||
'{second}' => \date("s"), | ||
]); | ||
@\file_put_contents($path, $message, \FILE_APPEND); | ||
return; | ||
} | ||
if(\is_object($this->_credentials['log']) && \method_exists($this->_credentials['log'], 'critical')){ | ||
$this->_credentials['log']->critical($message); | ||
} | ||
} | ||
|
||
private function _whereQuery(): string | ||
{ | ||
$isAndEmpty = empty($this->_STRUCTURE['where']['AND']); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 2.0 | ||
* @version 2.0.5 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|