Need help to write xquery in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tempex
Forum Newbie
Posts: 3
Joined: Wed Jul 11, 2012 4:38 am

Need help to write xquery in php

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Need help to write xquery in php

Post 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.
tempex
Forum Newbie
Posts: 3
Joined: Wed Jul 11, 2012 4:38 am

Re: Need help to write xquery in php

Post 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..
Post Reply