这是没有的工作声明?
$query_select_all = "SELECT * FROM TableName WHERE CAST(ColumnName AS UNSIGNED) REGEXP '111|114|115'";
$sql = $db->prepare($query_select_all);
$sql->execute();
想'111|114|115'
用作 php 变量(例如$data
)。
将代码更改为
$data = array('111|', '114|', '115');
$query_select_all = "SELECT * FROM TableName WHERE CAST(ColumnName AS UNSIGNED) REGEXP (?,?,?)";
$sql = $db->prepare($query_select_all);
$sql->execute($data);
$data
好像Array ( [0] => 111| [1] => 114| [2] => 115 )
执行语句 get 后SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)
。
假设某些事情不正确$data = array('111|', '114|', '115');
什么是正确的代码?