我想在SQL中使用LIKE形式的查询来自动实现这个php函数的文本字段:
function getNumOFAutoImplement($chaine){
$o_CAD = new connect();
$sql = 'SELECT * FROM tb_numero_affaire WHERE numero_OF LIKE \':numof%\'';
$param = array(":numof"=>$chaine);
$result = $o_CAD->read($sql, $param);
return $result;
}
功能运行良好我在我的函数中使用了这个请求:
$sql = 'SELECT * FROM tb_numero_affaire WHERE numero_OF LIKE :numof';
当我直接浏览phpMyAdmin SQL框中的以下行时,它也正常工作:
SELECT * FROM tb_numero_affaire WHERE numero_OF LIKE '%456%';
答案 0 :(得分:2)
将它与通配符绑定,例如;
function getNumOFAutoImplement($chaine){
$o_CAD = new connect();
$sql = 'SELECT * FROM tb_numero_affaire WHERE numero_OF LIKE :numof';
$param = array(":numof"=>$chaine.'%');
$result = $o_CAD->read($sql, $param);
return $result;
}
答案 1 :(得分:0)
$ sql =" SELECT * FROM tb_numero_affaire WHERE numero_OF LIKE'%"。$ chaine。"%'";