Jump to content

find method using chinese text


SIERRA
 Share

Recommended Posts

Hi

If we use chinese text in processwire find method like the below the error appears as 'Fatal error: Exception: Unknown Selector operator: ''' 

$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find("title={$title}");    
 

Could you please suggest on this. Thanks

 

Link to comment
Share on other sites

Thanks for your reply

if we give

$title="School Resumes";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find("title={$title}");

echo $findeventspage;

this displays id 

if we give

$title="School Resumes";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find('title={$title}');

echo $findeventspage;

this does not displays id 

if we give

$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find('title={$title}');

echo $findeventspage;

this also does not displays id. Actually we need to check the duplicates if availabe. 

Could you please suggest. Thanks

 

Link to comment
Share on other sites

It is better to use $sanitizer->selectorValue() to get the value in the correct shape to be used in a selector than to add quotes yourself, though @Zeka's example works.

$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$selector = "title=" . $sanitizer->selectorValue($title);
$findeventspage=$eventspage->events->findOne($selector);

If a hand coded selector doesn't yield any results, it's always worth checking whether the PHP file is in the correct encoding (UTF-8). Access restrictions may also come into play, which can be easily checked by appending ", include=all" to the selector to ignore access checks.

Link to comment
Share on other sites

@BitPoet Before posting my answer I have made tests with and without using $sanitizer->selectorValue. In this exact case, the page wasn't found after sanitizing of the string  "谢师宴 11am-1pm, Test服务奖 service award".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...