paraworld.MQL.query

Description

执行传入的MQL语句,并将结果返回

MQL语法类似于简化了的T-SQL。MQL必须以select、update、delete、insert into起始(目前只支持select)。

不区分大小字

保留关键字:
select  top  from  where  order  by  desc  asc  group  in  like  is  not  null  between  and  or  case  as  when  then  over  begin  end  inner  join  union  all

支持的函数:
cast  count  max  min  avg  sum  isnull  nullif  charindex  len  str  substring  left  right  
语法与T-SQL相同

MQL特有函数
Page(pageIndex, pageSize, order column):pageIndex是以1开始的页码,pageSize是每页的数据量,order column是排序字段与排序规则。Page函数只能用在最外层的select语句中;若已使用了Page函数,则不可再在where从句中指定order by语句。示例:取得当前所有在线用户,按用户创建时间倒序排序,并按每页10条数据分页,取得第一页的数据:select page(1,10,order by createDate desc), * from users where isOnline = 1

Parameters

Required Name Type Description
required query string 规范的MQL语句
optional appKey string 应用程序Key
sessionKey string 用户凭证

Return XML

(1)若是select语句,则返回类似于下面的XML格式:
<msg xmlns="">
        <list>
                <param index="1">
                        <uid type="string">f5f3de7a-05b2-42a0-bd78-415a939020c2</uid>
                        <uname type="string">clayman</uname>
                        <createDate type="string">2008-5-5 7:44:11</createDate>
                </param>
                <param index="2">
                        <uid type="string">6ea770c6-92b2-4b2b-86da-6f574641ec11</uid>
                        <uname type="string">andy</uname>
                        <createDate type="string">2008-5-5 7:36:12</createDate>
                </param>
                <param index="3">
                        <uid type="string">8ec11316-bc2e-491d-8f18-667501687e69</uid>
                        <uname type="string">ParaEngine</uname>
                        <createDate type="string">2008-5-5 7:36:05</createDate>
                </param>
        </list>
        <query type="string">
                with __TEMPTABLE as(select Row_Number() over(order by [createDate] desc) [RowNumber], 
                       [uid],[uname],[createdate] from [vUsers] where [createdate] > '2008-1-1')
                       select * from __TEMPTABLE where RowNumber between 1 and 3
        </query>
</msg>
(2)若是update、delete、insert语句,则返回类似于下面的XML:
<msg>
        <isSuccess>true</isSuccess>
        <query type="string">
                update users set email = 'aaa@gmail.com' where uid = 'f5f3de7a-05b2-42a0-bd78-415a939020c2'
        </query>
</msg>
(3)若发生异常,则返回类似于下面的XML:
<msg>
        <errorCode>494</errorCode>
        <query type="string">
                select uid,uname,createdate from users wherer createdate > '2008-1-1'
        </query>
</msg>

Return JSON

(1)若是select语句,则返回类似于下面的JSON格式:
{"list":[{"RowNumber":"1","uid":"82d516c3-48b7-4619-a2ca-ee3b1d3e1966","uname":"abc","createdate":"2008-12-6 9:08:22"},
{"RowNumber":"2","uid":"eb96d97b-98ce-43b0-abd1-74661bc222ae","uname":"grass","createdate":"2008-12-3 3:16:22"},
{"RowNumber":"3","uid":"ffa65436-9828-4324-a443-10771658d53a","uname":"qwerttt","createdate":"2008-12-3 3:12:08"}],
"query":"with __TEMPTABLE as(select Row_Number() over(order by [createDate] desc) [RowNumber], 
[uid],[uname],[createdate] from [vUsers] where [createdate] > '2008-1-1') select * from __TEMPTABLE where RowNumber between 1 and 3"}

Tables

users
fields
Name Type Description
uid GUID 用户的唯一标识符
nid string 用户的数字ID
uname string 用户名
nickName string 用户昵称
firstName string
lastName string
birthday datetime 生日
gender string 性别
registerArea string 注册所在地
photo string 用户图像URL
createDate datetime 注册时间
email string 用户的电子邮箱地址
isApproved boolean 是否已激活
isLocked boolean 是否被锁定
isOnline boolean 当前是否在线
支持的MQL语句
select语句 支持
update语句 不支持
delete语句 不支持
insert语句 不支持

friends
fields

Name Type Description
id int 主键
uid1 GUID 用户ID
uid2 GUID 好友的用户ID
addDate datetime 添加好友的时间
支持的MQL语句
select语句 支持
update语句 不支持
delete语句 不支持
insert语句 不支持

WorldUser
fields

Name Type Description
worldID int 世界ID
uid GUID 用户ID
addDate datetime 创建此数据的时间,即用户加入世界的时间
支持的MQL语句
select语句 支持
update语句 不支持
delete语句 不支持
insert语句 不支持

Error Codes

当发生异常时,返回数据中会有一个“errorCode”节点,该节点记录了错误码。0:无异常 500:未知错误 499:提供的数据不完整 498:非法的访问 494:语法错误
Topic revision: r12 - 2009-01-16 - CaoYF
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback