2
0
forked from Wavyzz/dolibarr

Fix sqlforlike when searching with like and _ string

This commit is contained in:
Laurent Destailleur
2023-04-15 01:24:50 +02:00
parent 98e389bdce
commit f425bd4654
4 changed files with 41 additions and 3 deletions

View File

@@ -157,6 +157,44 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase
print __METHOD__."\n";
}
/**
* testEscape
*
* @return string
*/
public function testEscape()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$a = 'abc"\'def';
print $a;
$result = $db->escape($a); // $result must be abc\"\'def
$this->assertEquals('abc\"\\\'def', $result);
}
/**
* testEscapeForLike
*
* @return string
*/
public function testEscapeForLike()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$a = 'abc"\'def_ghi%klm\\nop';
//print $a;
$result = $db->escapeforlike($a); // $result must be abc"'def\_ghi\%klm\\nop
$this->assertEquals('abc"\'def\_ghi\%klm\\\\nop', $result);
}
/**
* testSql
*