Skip to content
Snippets Groups Projects
Verified Commit 0782f2b4 authored by Damien's avatar Damien
Browse files

[REFACTORING] DatabasePdo

parent b38bef7e
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,6 @@ foreach ($customs as $custom) { ...@@ -46,7 +46,6 @@ foreach ($customs as $custom) {
} }
} }
\SrcCore\models\DatabasePDO::reset();
$db = new \SrcCore\models\DatabasePDO(['customId' => $custom]); $db = new \SrcCore\models\DatabasePDO(['customId' => $custom]);
foreach ($priorities as $key => $priority) { foreach ($priorities as $key => $priority) {
if ($priority['default_priority'] == 'true') { if ($priority['default_priority'] == 'true') {
......
...@@ -14,7 +14,6 @@ foreach ($customs as $custom) { ...@@ -14,7 +14,6 @@ foreach ($customs as $custom) {
if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
continue; continue;
} }
\SrcCore\models\DatabasePDO::reset();
$db = new \SrcCore\models\DatabasePDO(['customId' => $custom]); $db = new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$query = "SELECT r2.res_id as convert_res_id from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id <> 0"; $query = "SELECT r2.res_id as convert_res_id from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id <> 0";
......
...@@ -202,7 +202,6 @@ try { ...@@ -202,7 +202,6 @@ try {
exit(); exit();
} }
\SrcCore\models\DatabasePDO::reset();
$GLOBALS['db'] = new \SrcCore\models\DatabasePDO(['customId' => $GLOBALS['CustomId']]); $GLOBALS['db'] = new \SrcCore\models\DatabasePDO(['customId' => $GLOBALS['CustomId']]);
$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR . $GLOBALS['batchName'] .'_error.lck'; $GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR . $GLOBALS['batchName'] .'_error.lck';
......
...@@ -124,8 +124,8 @@ class DatabasePDO ...@@ -124,8 +124,8 @@ class DatabasePDO
$queryString = str_ireplace('CURRENT_TIMESTAMP', 'SYSDATE', $queryString); $queryString = str_ireplace('CURRENT_TIMESTAMP', 'SYSDATE', $queryString);
} }
$originalData = $data;
if (!empty($data)) { if (!empty($data)) {
$originalData = $data;
$tmpData = []; $tmpData = [];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
...@@ -151,16 +151,9 @@ class DatabasePDO ...@@ -151,16 +151,9 @@ class DatabasePDO
$query->execute($data); $query->execute($data);
} catch (\PDOException $PDOException) { } catch (\PDOException $PDOException) {
if ( if (strpos($PDOException->getMessage(), 'Admin shutdown: 7') !== false || strpos($PDOException->getMessage(), 'General error: 7') !== false) {
strpos($PDOException->getMessage(), 'Admin shutdown: 7') !== false ||
strpos($PDOException->getMessage(), 'General error: 7') !== false
) {
$db = new DatabasePDO(); $db = new DatabasePDO();
if ($originalData) { $query = $db->query($originalQuery, $originalData);
$db->query($originalQuery, $originalData);
} else {
$db->query($originalQuery);
}
} else { } else {
$param = implode(', ', $data); $param = implode(', ', $data);
$file = fopen('queries_error.log', 'a'); $file = fopen('queries_error.log', 'a');
...@@ -196,12 +189,6 @@ class DatabasePDO ...@@ -196,12 +189,6 @@ class DatabasePDO
return ['where' => $where, 'limit' => $limit]; return ['where' => $where, 'limit' => $limit];
} }
public static function reset()
{
$this->pdo = null;
self::$preparedQueries = [];
}
public function getType() public function getType()
{ {
return self::$type; return self::$type;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment