Need example of binding LIKE DB2 statements in PHP
I am trying to do something similar to this...
$sql = "SELECT * FROM foo WHERE user = ? AND order LIKE ?%"
$stmt = db2_prepare($conn, $sql);
db2_bind_param($stmt, 1, "userName", DB2_PARAM_IN);
db2_bind_param($stmt, 2, "orderNum", DB2_PARAM_IN);
db2_execute($stmt);
Of course, its not the right way to do LIKE ?%. I'm just l开发者_Go百科ooking for the correct way to bind a parameter like that but also use the % wildcard.
Just stick the parameter with the wildcard characters in the string. You'll want to do something like (see example #12):
$sql = "SELECT * FROM foo WHERE user = ? AND order LIKE ?"
and
$orderNum = '%' . $your_order_num . '%';
db2_bind_param($stmt, 2, "orderNum", DB2_PARAM_IN);
精彩评论