Skip to content

Commit f427269

Browse files
committed
Small fix
1 parent ff605b8 commit f427269

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

webfiori/database/mssql/MSSQLQuery.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,9 @@ private function _insertHelper(array $colsKeysArr, array $valuesToInsert) {
300300
if ($val !== null) {
301301
$cleanedVal = $column->cleanValue($val);
302302

303-
if ($type == 'tinyblob' || $type == 'mediumblob' || $type == 'longblob') {
303+
if ($type == 'binary' || $type == 'varbinary') {
304304
$fixedPath = str_replace('\\', '/', $val);
305305
set_error_handler(null);
306-
$this->setIsBlobInsertOrUpdate(true);
307306

308307
if (strlen($fixedPath) != 0 && file_exists($fixedPath)) {
309308
$file = fopen($fixedPath, 'r');
@@ -313,18 +312,18 @@ private function _insertHelper(array $colsKeysArr, array $valuesToInsert) {
313312
$fileContent = fread($file, filesize($fixedPath));
314313

315314
if ($fileContent !== false) {
316-
$data = '\''.addslashes($fileContent).'\'';
315+
$data = '0x'. bin2hex($fileContent);
317316
$valsArr[] = $data;
318317
} else {
319318
$valsArr[] = 'null';
320319
}
321320
fclose($file);
322321
} else {
323-
$data = '\''.addslashes($val).'\'';
322+
$data = '0x'. bin2hex($val);
324323
$valsArr[] = $data;
325324
}
326325
} else {
327-
$data = '\''.addslashes($cleanedVal).'\'';
326+
$data = '0x'. bin2hex($cleanedVal).'';
328327
$valsArr[] = $data;
329328
}
330329
restore_error_handler();
@@ -349,8 +348,9 @@ private function _insertHelper(array $colsKeysArr, array $valuesToInsert) {
349348
if ($defaultVal !== null) {
350349
$colsNamesArr[] = $colObj->getName();
351350
$type = $colObj->getDatatype();
352-
353-
if ($defaultVal == 'now' || $defaultVal == 'current_timestamp' || $defaultVal == 'now()') {
351+
if ($type == 'boolean' || $type == 'bool') {
352+
$valsArr[] = $colObj->cleanValue($defaultVal);
353+
} else if ($defaultVal == 'now' || $defaultVal == 'current_timestamp' || $defaultVal == 'now()') {
354354
if ($type == 'datetime2') {
355355
$valsArr[] = "'".date('Y-m-d H:i:s')."'";
356356
} else if ($type == 'time') {

webfiori/database/mysql/MySQLQuery.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,9 @@ private function _insertHelper(array $colsKeysArr, array $valuesToInsert) {
559559
if ($defaultVal !== null) {
560560
$colsNamesArr[] = $colObj->getName();
561561
$type = $colObj->getDatatype();
562-
563-
if (($type == 'datetime' || $type == 'timestamp') && ($defaultVal == 'now()' || $defaultVal == 'current_timestamp')) {
562+
if ($type == 'boolean' || $type == 'bool') {
563+
$valsArr[] = $colObj->cleanValue($defaultVal);
564+
} else if (($type == 'datetime' || $type == 'timestamp') && ($defaultVal == 'now()' || $defaultVal == 'current_timestamp')) {
564565
$valsArr[] = "'".date('Y-m-d H:i:s')."'";
565566
} else {
566567
$valsArr[] = $colObj->cleanValue($defaultVal);

0 commit comments

Comments
 (0)