This function normalize fields and strings with or without accents, to where (commands sql).
This functions converts fields and strings with special characters into fields and strings with characters normalized and convert this to uppercase
<?php
function normalize($field,$string,$is_normalized,$type){
if ($is_normalized) // if is true, the field is normalized
$field_normalized = $field;
else
// normalize the field
$field_normalized = "upper(translate
(".$field.",'".$characters_with_accents."','".$characters_norm."'))";
if (strcmp($type,"%like%") == 0) // the type of comparasion is 'like', in both sides (left
and right)
return $field_normalized." like '%".$string_normalized."%'";
elseif (strcmp($type,"like%") == 0) // the type of comparasion is 'like', in left side
return $field_normalized." like '".$string_normalized."%'";
elseif (strcmp($type,"%like") == 0) // the type of comparasion is 'like', in right side
return $field_normalized." like '%".$string_normalized."'";
elseif (strcmp($type,"=") == 0) // the type of comparasion is '='
return $field_normalized." = '".$string_normalized."'";
}
?>
Usage Example
<?php
$sql1 = "select * from people where ".normalize("name","S�nia Concei��o",false,"%like%");
$sql2 = "select * from keywords where ".normalize("key","web",true,"like%");
$sql3 = "select * from letters where ".normalize("first_letter","a",true,"=");
?>
This examples gives:
<?php
$sql1 = "select * from people where upper(translate(name,'�����������������������������
�','aeiouaeiouacouAEIAEOUAEIOUACOU') like '%SONIA CONCEICAO%'";
$sql2 = "select * from keywords where key like 'WEB%'";
$sql3 = "select * from letters where where first_letter='A'";
?>
This is very useful in command's Sql, and works fine with Oracle.
Is so mutch useful in search's where the field and respective string is not normalized.
Srikanth Turaga wrote :1045
Can someone send me either a working example of PHP and WSDL or atleast show me the link where I can find one. I have been trying a couple fo examples and none of them works. A working example (even a simple one would do) would be appreciated a lot.