车辆管理 随笔

1、未明确定义列           分页时查询sql存在重名

2、mybatis中# 和¥区别 

1 #是将传入的值当做字符串的形式,eg:select id,name,age from student where id =#{id},当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id ='1'.

 2 $是将传入的数据直接显示生成sql语句,eg:select id,name,age from student where id =${id},当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id = 1.

 3 使用#可以很大程度上防止sql注入。(语句的拼接)

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

 5 在大多数情况下还是经常使用#,但在不同情况下必须使用$. 

我觉得#与的区别最大在于:#{} 传入值时,sql解析时,参数是带引号的,而的区别最大在于:#{} 传入值时,sql解析时,参数是带引号的,而{}穿入值,sql解析时,参数是不带引号的。

一 : 理解mybatis中 $与#

    在mybatis中的$与#都是在sql中动态的传入参数。

    eg:select id,name,age from student where name=#{name}  这个name是动态的,可变的。当你传入什么样的值,就会根据你传入的值执行sql语句。

二:使用$与#

   #{}: 解析为一个 JDBC 预编译语句(prepared statement)的参数标记符,一个 #{ } 被解析为一个参数占位符 。

   ${}: 仅仅为一个纯碎的 string 替换,在动态 SQL 解析阶段将会进行变量替换。

  name-->cy

 eg:  select id,name,age from student where name=#{name}   -- name='cy'

       select id,name,age from student where name=${name}    -- name=cy

3、在oracle使用concat函数时需注意

oracle中使用concat,concat只能连接两个字符,而“||”可以连接多个字符。

如下

用concat时:

①.sql>select concat('aa','bb') from test;

     concat('aa','bb')

     ---------------------

     aabb

②.sql>select concat('aa','bb','cc') from test;

     0RA-00909:invalid number of arguments

     因此,用concat连接多个字符时,需要嵌套

     sql>select concat(concat('aa','bb'),'cc') from test;

     concat(concat('aa','bb'),'cc')

     ------------------------------------

     aabbcc

 

2018.04.02 测试环境和客户端联调时,因使用开发环境的token导致 获取token异常,总结:测试token和开发token是分开的
posted @ 2018-03-28 18:00  极致网络科技  阅读(153)  评论(0编辑  收藏  举报