Codeigniter ActiveRecord:Where子句与自定义字符串

时间:2016-07-06 10:44:38

标签: codeigniter activerecord where-clause

我想使用CI活动记录搜索以下字符串。

  

点击您要使用的活动或预订代码。

我的查询如下:

$this->db->selet("id");
$this->db->where("column_name", "Click on the Event or Booking Code you would like to use.");
$this->db->from("table_name")
$ret = $this->db->get();

但它不起作用,因为CI将转义字符串并生成select查询,如下所示:

  

SELECT id FROM table_name WHERE column_name ='点击活动或   Booking Code you would喜欢使用。'

此问题是否有解决方法?

1 个答案:

答案 0 :(得分:0)

这应该有效:

         // JSON Object
        JSONObject testJson = new JSONObject();

        testJson.put("connectionname", "drinkss");
        testJson.put("jdbcurl", "jdbc:mysql://localhost/drink");
        testJson.put("schema", "datasources/dr.xml");
        testJson.put("driver", "com.mysql.jdbc.Driver");
        testJson.put("username", "root");
        testJson.put("password", "211218");
        testJson.put("connectiontype", "MONDRIAN");

        // For Posting datasource into server


        Response document1 = Jsoup
                    .connect(
                            "http://localhost:8080/saiku/rest/saiku/admin/datasources/")
                    .header("Content-Type", "application/json")
                    .requestBody(testJson.toString())
                    .data(testJson)
                    .ignoreContentType(true)
                    .referrer("http://localhost:8080/")
                    .cookie("JSESSIONID", res.cookie("JSESSIONID"))
                    .userAgent(
                            "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36")
                    .method(Method.POST).timeout(10000).execute();
            System.out.println("post successfully....."
                    + testJson.toJSONString());