各位先進 小弟有一事想要請教各位大大
因目前專案有一功能是需要LIKE多組字串,以下程式
$p_search = explode(" ",$p_search_name);
$product_info_sql = $db->prepare("SELECT no FROM product_info
where name LIKE '%".$p_search_name."%' ");
foreach($p_search as $k){
$product_info_sql = $db->prepare( " OR name LIKE '%$k%' ");
}
$product_info_sql = $db->prepare(" AND status = ? order by sequence
DESC limit " . $startRow_records . ",$pageRow_records");
$product_info_sql->execute(array('1'));
主要是判斷有幾組字串(關鍵字),產生多組OR name LIKE
但是PDO好像不能這樣用,還想請大大們解惑
萬分感謝