Skip to content

Commit 8b14e18

Browse files
authored
Merge pull request #16 from WebFiori/dev
Dev
2 parents 9732bea + d847ff6 commit 8b14e18

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

tests/mysql/MySQLQueryBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function testSelectWithWhere012() {
311311
)->where('id', '!=', null)
312312
);
313313
// Expr(Expr(Cond) Cond)
314-
$this->assertEquals('select * from [users] where [users].[id] is null and [users].[id] is not null', $schema->getLastQuery());
314+
$this->assertEquals('select * from `users` where `users`.`id` is null and `users`.`id` is not null', $schema->getLastQuery());
315315
}
316316
/**
317317
* @test

webfiori/database/mssql/MSSQLConnection.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ private function _selectQuery() {
204204
private function _setErr() {
205205
$allErrs = sqlsrv_errors(SQLSRV_ERR_ERRORS);
206206
$lastErr = $allErrs[count($allErrs) - 1];
207-
$this->sqlState = $lastErr['SQLSTATE'];
208-
$this->setErrMessage($lastErr['message']);
209-
$this->setErrCode($lastErr['code']);
207+
208+
if (strpos($lastErr['message'], 'The statement has been terminated') === false) {
209+
$this->sqlState = $lastErr['SQLSTATE'];
210+
$this->setErrMessage($lastErr['message']);
211+
$this->setErrCode($lastErr['code']);
212+
}
210213
}
211214
}

webfiori/database/mssql/MSSQLQuery.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ private function _insertHelper(array $colsKeysArr, array $valuesToInsert) {
301301
$cleanedVal = $column->cleanValue($val);
302302

303303
if ($type == 'binary' || $type == 'varbinary') {
304-
$fixedPath = str_replace('\\', '/', $val);
304+
//chr(0) to remove null bytes in path.
305+
$fixedPath = str_replace('\\', '/', str_replace(chr(0), '', $val));
305306
set_error_handler(null);
306307

307308
if (strlen($fixedPath) != 0 && file_exists($fixedPath)) {

webfiori/database/mysql/MySQLQuery.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ private function _insertHelper(array $colsKeysArr, array $valuesToInsert) {
511511
$cleanedVal = $column->cleanValue($val);
512512

513513
if ($type == 'tinyblob' || $type == 'mediumblob' || $type == 'longblob') {
514-
$fixedPath = str_replace('\\', '/', $val);
514+
//chr(0) to remove null bytes in path.
515+
$fixedPath = str_replace('\\', '/', str_replace(chr(0), '', $val));
515516
set_error_handler(null);
516517
$this->setIsBlobInsertOrUpdate(true);
517518

0 commit comments

Comments
 (0)