2013-11-15 29 views
-1

如何將其轉換爲使用mysqli & php的預準備語句?如何將其轉換爲準備好的語句

$ DB->的executeQuery( '更新產品集prod_ops_txt =替換(prod_ops_txt,「/'。$ IMG。 '.JPG 「 」「),其中prod_ops_txt贊(」 %/'。$ IMG「。的.jpg%「)');

我在找做這樣的事情:

$語句= $ mysqli->準備(「更新的產品設置prod_ops_txt =替換(prod_ops_txt, 」「),其中prod_ops_txt贊(? 「〜%%」)');

$ thisImg ='/'。 $ img。名爲.jpg;

$ stmt-> bind_param('ss',$ thisImg,$ thisImg);

$ stmt-> execute();

$ stmt-> close();

+0

定義$ db對於這個問題並不重要。 – user1304362

回答

0

花了一點擺弄,但我終於找到了正確的語法自己:

$語句= $ mysqli->準備(「更新產品集product_options_text =替換(prod_opts_txt, 」「 )where prod_opts_txt Like(?)');

$ thisImg ='/'。 $ img。名爲.jpg;

$ thisImgMatch ='%/'。 $ img。名爲.jpg%';

$ stmt-> bind_param('ss',$ thisImg,$ thisImgMatch);

$ stmt-> execute();

$ stmt-> close();