Mybatis 中 與 的區別

2022-05-06 16:39:06 字數 777 閱讀 1470

1 #是將傳入的值當做字串的形式,eg:select id,name,age from student where id =#,當前端把id值1,傳入到後台的時候,就相當於 select id,name,age from student where id ='1'.

2 $是將傳入的資料直接顯示生成sql語句,eg:select id,name,age from student where id =$,當前端把id值1,傳入到後台的時候,就相當於 select id,name,age from student where id = 1.

3 使用#可以很大程度上防止sql注入。

4 但是如果使用在order by 中就需要使用 $.

5 在大多數情況下還是經常使用#,但在不同情況下必須使用$. 

1 #是將傳入的值當做字串的形式,eg:select id,name,age from student where id =#,當前端把id值1,傳入到後台的時候,就相當於 select id,name,age from student where id ='1'.

2 $是將傳入的資料直接顯示生成sql語句,eg:select id,name,age from student where id =$,當前端把id值1,傳入到後台的時候,就相當於 select id,name,age from student where id = 1.

3 使用#可以很大程度上防止sql注入。

4 但是如果使用在order by 中就需要使用 $.

5 在大多數情況下還是經常使用#,但在不同情況下必須使用$. 

mybatis 中 與 的區別

mybatis ibatis中 和 的區別 1.將傳入的資料都當成乙個字串,會對自動傳入的資料加乙個雙引號。如 order by user id 如果傳入的值是111,那麼解析成sql時的值為order by 111 如果傳入的值是id,則解析成的sql為order by id 2.將傳入的資料直接...

mybatis 中 與 的區別

mybatis將 解釋為jdbc prepared statement 的乙個 引數標記 而將 解釋為 字串替換 1.將傳入的資料都當成乙個字串,會對自動傳入的資料加乙個雙引號。如 order by user id 如果傳入的值是111,那麼解析成sql時的值為order by 111 如果傳入的值...

mybatis 中 與 的區別

mybatis ibatis中 和 的區別 1.將傳入的資料都當成乙個字串,會對自動傳入的資料加乙個雙引號。如 order by user id 如果傳入的值是111,那麼解析成sql時的值為order by 111 如果傳入的值是id,則解析成的sql為order by id 2.將傳入的資料直接...