谁能帮我如何在字符串中绑定变量?
Can anyone help me how to bind a variable in a String?
谁能帮我解决这个问题。
function get_shareSearch($conn, $searchBy) {
$id = "";
if(isset($_GET['share']))
{
$id = $_GET['share'];
if($id == "%")
{
$id = "This is not going to work";
}
}
$statement = db_create_statement($conn, "SELECT DISTINCT * FROM shares WHERE company LIKE '%" . $id . "%' OR issue_date LIKE '%" . $id ."%' ORDER BY $searchBy ASC" );
db_bind($statement, ':id', $id);
$resultset = db_fetch_resultset($statement);
return $resultset;
}
function db_bind($statement, $name, $value) {
return oci_bind_by_name($statement, $name, $value, 30);
}
警告:oci_bind_by_name(): ORA-01036: 非法变量
任何人都可以帮助我如何更改 oracle 语句中的变量 id,以便我仍然可以对其进行连接以绑定变量吗?谢谢。
db_bind($statement, ':id', $id);
要在字符串中绑定变量,必须将它们连接起来(oracle 表示法):
SELECT DISTINCT * FROM shares WHERE company LIKE '%' || :id || '%' OR issue_date LIKE '%' || :id || '%' ORDER BY $searchBy ASC
谁能帮我解决这个问题。
function get_shareSearch($conn, $searchBy) {
$id = "";
if(isset($_GET['share']))
{
$id = $_GET['share'];
if($id == "%")
{
$id = "This is not going to work";
}
}
$statement = db_create_statement($conn, "SELECT DISTINCT * FROM shares WHERE company LIKE '%" . $id . "%' OR issue_date LIKE '%" . $id ."%' ORDER BY $searchBy ASC" );
db_bind($statement, ':id', $id);
$resultset = db_fetch_resultset($statement);
return $resultset;
}
function db_bind($statement, $name, $value) {
return oci_bind_by_name($statement, $name, $value, 30);
}
警告:oci_bind_by_name(): ORA-01036: 非法变量
任何人都可以帮助我如何更改 oracle 语句中的变量 id,以便我仍然可以对其进行连接以绑定变量吗?谢谢。
db_bind($statement, ':id', $id);
要在字符串中绑定变量,必须将它们连接起来(oracle 表示法):
SELECT DISTINCT * FROM shares WHERE company LIKE '%' || :id || '%' OR issue_date LIKE '%' || :id || '%' ORDER BY $searchBy ASC