Page 1 of 1

Need help to write xquery in php

Posted: Wed Jul 11, 2012 4:44 am
by tempex
Hello,

Need a little help to execute query below in php
The query goes well in DB2 command editor, but I do not have any idea how to execute it in php.

Code: Select all

xquery for $d in db2-fn:xmlcolumn('TERM.TERM')
where fn:contains($d/term, '$keyword') 
return $d
Thanks in advanced.

Re: Need help to write xquery in php

Posted: Wed Jul 11, 2012 2:33 pm
by requinix
Try a simple

Code: Select all

"xquery for \$d in db2-fn:xmlcolumn('TERM.TERM')\nwhere fn:contains(\$d/term, '$keyword')\nreturn \$d"
(assuming $d is a DB2 variable and $keyword is a PHP variable). I don't think the newlines are necessary but I threw them in anyways.

If you're asking about how to query a DB2 database in general then you need to find yourself a tutorial on the subject.

Re: Need help to write xquery in php

Posted: Wed Jul 11, 2012 10:48 pm
by tempex
Thank you very much for the advice.

It's work.

However if only the $keyword is in English.
If I insert Japanese character in there, no result is return.
I wonder why..