|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
也就是说在php本地调用pdoprepare中的mysql_real_escape_string来操作query,使用的是本地单字节字符集,即编码为xbfx5cx27,并带入到mysql中查询,由于使用setnames设置了连接字符集.
alterfunctiondbo.IDTrue--考证十八位身份证是不是准确
(
@IDvarchar(18)
)
returnsbit
as
begin
--考证格局是不是准确
declare@RESbit
declare@Wtable(rnint,valint)
insertinto@W(rn,val)
select1,7
unionselect2,9
unionselect3,10
unionselect4,5
unionselect5,8
unionselect6,4
unionselect7,2
unionselect8,1
unionselect9,6
unionselect10,3
unionselect11,7
unionselect12,9
unionselect13,10
unionselect14,5
unionselect15,8
unionselect16,4
unionselect17,2
unionselect18,1
declare@Atable(rwnint,valvarchar(1))
insertinto@A(rwn,val)
select0,1
insertinto@A(rwn,val)
select1,0
insertinto@A(rwn,val)
select2,X
insertinto@A(rwn,val)
select3,9
insertinto@A(rwn,val)
select4,8
insertinto@A(rwn,val)
select5,7
insertinto@A(rwn,val)
select6,6
insertinto@A(rwn,val)
select7,5
insertinto@A(rwn,val)
select8,4
insertinto@A(rwn,val)
select9,3
insertinto@A(rwn,val)
select10,2
declare@iint
declare@jint
declare@Sint
iflen(@ID)=18
begin
select@S=0,@i=1
declare@IDIint
declare@WIint
declare@PIIvarchar(1)
while@i<=17
begin
select@PII=substring(@ID,@i,1)
if@PIIlike[0-9]
begin
select@IDI=convert(int,@PII)
select@WI=valfrom@Wwherern=@i
select@j=@IDI*@WI
select@S=@S+@j
select@i=@i+1
end
else
begin
select@RES=0
return@RES
end
end
select@S=@S%11
select@IDI=convert(int,substring(@ID,18,1))
declare@pivarchar(1)
select@pi=valfrom@Awhererwn=@S
if@pi=@IDI
select@RES=1
else
select@RES=0
end
else
begin
select@RES=0
end
return@RES
end
go
declare@pcbit
select@pc=dbo.IDTrue(420324198101031224)
select@pc
go
alterfunctionSFZ15To18--十五位升十八
(
@sfzvarchar(15)
)
returnsvarchar(18)
as
begin
declare@Wtable(rnint,valint)
insertinto@W(rn,val)
select1,7
unionselect2,9
unionselect3,10
unionselect4,5
unionselect5,8
unionselect6,4
unionselect7,2
unionselect8,1
unionselect9,6
unionselect10,3
unionselect11,7
unionselect12,9
unionselect13,10
unionselect14,5
unionselect15,8
unionselect16,4
unionselect17,2
unionselect18,1
declare@Atable(rwnint,valvarchar(1))
insertinto@A(rwn,val)
select0,1
insertinto@A(rwn,val)
select1,0
insertinto@A(rwn,val)
select2,X
insertinto@A(rwn,val)
select3,9
insertinto@A(rwn,val)
select4,8
insertinto@A(rwn,val)
select5,7
insertinto@A(rwn,val)
select6,6
insertinto@A(rwn,val)
select7,5
insertinto@A(rwn,val)
select8,4
insertinto@A(rwn,val)
select9,3
insertinto@A(rwn,val)
select10,2
declare@NEWIDvarchar(18)
select@NEWID=substring(@sfz,1,6)+19+substring(@sfz,7,9)
declare@iint
declare@jint
declare@Sint
select@S=0,@i=1
declare@IDIint
declare@WIint
declare@PIIvarchar(1)
while@i<=17
begin
select@PII=substring(@NEWID,@i,1)
if@PIIlike[0-9]
begin
select@IDI=convert(int,@PII)
select@WI=valfrom@Wwherern=@i
select@j=@IDI*@WI
select@S=@S+@j
select@i=@i+1
end
else
begin
return
end
end
select@S=@S%11
declare@pivarchar(1)
select@pi=valfrom@Awhererwn=@S
select@NEWID=@NEWID+@pi
return@NEWID
end
go
selectdbo.SFZ15To18(420324810103153)
go
--日期是不是准确
alterfunctionChkYMD(
@yint,
@mtinyint,
@dtinyint,
@cyint
)
returnsbit
as
begin
declare@resbit
select@res=1
if@y<1900or@y>@cy
begin
select@res=0
return@res
end
if@m=1or@m=3or@m=5or@m=7or@m=8or@m=10or@m=12
begin
if(@d<1)or(@d>31)
begin
select@res=0
return@res
end
end
if@m=2
begin
if((@y%4)=0)and((@y%100)0)or((@y%400)=0)
begin--闰年
if(@d<1)or(@d>29)
begin
select@res=0
return@res
end
endelse
begin
if(@d<1)or(@d>28)
begin
select@res=0
return@res
end
end
end
if@m=4or@m=6or@m=9or@m=11
begin
if(@d<1)or(@d>30)
begin
select@res=0
return@res
end
end
return@res
end
go
selectdbo.chkymd(1981,1,3,Year(getdate()))
go
/*
y:年,m:月,d:日。在参数都只传进响应的整数
前往值:0礼拜一
1礼拜2
2礼拜3
3礼拜4
4礼拜5
5礼拜6
6礼拜7
*/
alterfunctionGetWeekDay(
@yint,
@mint,
@dint
)
returnstinyint
as
begin
declare@atinyint
select@a=7
if@m=1or@m=2
begin
select@m=@m+12
select@y=@y-1
end
select@a=(@d+2*@m+3*(@m+1)/5+@y+@y/4-@y/100+@y/400)%7;
return@a
end
go
selectdbo.getweekday(2004,12,10)
Mysql的存储引擎接口定义良好。有兴趣的开发者可以通过阅读文档编写自己的存储引擎。 |
|