简体   繁体   English

谁能帮我如何在字符串中绑定变量?

[英]Can anyone help me how to bind a variable in a String?

Can someone help me in this problem. 有人可以帮我解决这个问题。

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);

} }

Warning: oci_bind_by_name(): ORA-01036: illegal variable 警告:oci_bind_by_name():ORA-01036:非法变量

can any one help me how to change variable id in the oracle statement so I could still have concatination plus to that to be able to bind the variable? 任何人都可以帮助我如何在oracle语句中更改变量id,以便我仍然可以使用隐含方法来绑定变量吗? Thank you. 谢谢。

  db_bind($statement, ':id', $id);

要将变量绑定到字符串中,必须将它们串联(oracle表示法):

 SELECT DISTINCT * FROM shares WHERE company LIKE '%' || :id || '%' OR issue_date LIKE '%' || :id || '%' ORDER BY $searchBy ASC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM