Php 从数据库检索结果

Php 从数据库检索结果,php,sql,regex,Php,Sql,Regex,以下是我的表格结构: Table Call_Log id | StationId | LoginId | keystroke | timestamp 我需要能够找到在按下“5”键之后,在按下“Q”键之间按下“1”键的次数 EX: 'Q','5','1','Q' will return true but 'Q','5','2','Q' will return false 此外,我需要以某种方式进行操作,以便我可以向find列添加更多键,它也可以找到它们。因此,如果我想在“5”和“1”之后查

以下是我的表格结构:

Table Call_Log

id | StationId | LoginId |  keystroke | timestamp
我需要能够找到在按下“
5
”键之后,在按下“
Q
”键之间按下“
1
”键的次数

EX: 'Q','5','1','Q' will return true
but 'Q','5','2','Q' will return false
此外,我需要以某种方式进行操作,以便我可以向find列添加更多键,它也可以找到它们。因此,如果我想在“
5
”和“
1
”之后查找键
3
,它可以执行类似的操作

Ex: 'Q','5','1','3','Q' will return true
but 'Q','5','1','2','Q' will return false

请告诉我你没有记录mysql数据库中的每一次击键。你能给你的搜索设置一个时间限制吗?如果你能给搜索设置一个时间限制,这在FSA中是很容易实现的。因为这只是一个FSA问题。你能发布你尝试过的代码吗?我们怎么知道这些按键的编码?!我建议使用每次击键产生的控制代码,并存储击键所代表的数字的位掩码。这是唯一安全的方法。等等,我知道!有一个包含两列的
bit\u lookup
表:
bit\u id
(主键)和
bit
(数据类型分别为
smallint
bit(1)
)。然后您可以有一个
击键查找
表,其中包含
击键id
(主键)、
位id
(外键指
位查找
)和
位秩
(以便我们可以确定特定击键的位顺序)。我们还可以有一个
keystroke\u name
表,其中包含列
keystroke\u id
(外键对应于
keystroke\u查找
表)和
keystroke
(数据类型char(1))。然后,所有其他表都可以引用
击键id
SELECT count(*) FROM (
  SELECT
    IF(
      @matchstring='Q' AND keystroke='5', 
      @matchsting:='Q5',
      IF(
        @matchstring='Q5' AND keystroke='1',
        @matchstring:='Q51',
        IF (@matchstring='Q51' AND keystroke='Q',
          @matchstring:='Q51Q',
          @matchstring:=keystroke
        )
      )
    ) AS matchpart
  FROM
    (SELECT @matchstring:=''),
    Call_Log
  WHERE
    -- Your criteria here, might be "StationID=blah"
  ORDER BY
    Call_Log.`timestamp`
) AS baseview
WHERE matchpart='Q51Q'
;