在php中匹配未转义的字符(match unescaped characters in php)
我需要一个正则表达式来匹配PHP中的单个/字符串。
"bla bla bla/bla bla bla" //The regexp must match the / character "bla bla // bla bla / bla bla" //The regexp must match only the last / not the first beacuse it is followed by another /
所以我只希望没有转义/。
i need a regexp to match only single / in a string in PHP.
"bla bla bla/bla bla bla" //The regexp must match the / character "bla bla // bla bla / bla bla" //The regexp must match only the last / not the first beacuse it is followed by another /
so i want only unescaped /.
原文:https://stackoverflow.com/questions/1345618
最满意答案
我认为你的第二个触发器需要使用实际表中的值,而不是插入/删除的表来填充日志表 - 插入/删除将始终具有未更改的原始值,而更改的值将显示在表中。 使第二个触发器成为“After”触发器,因此您不必使用sp_settriggerorder。 像这样,例如:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[trg_Trig1] ON [dbo].[TestTable] FOR INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; update TestTable set [value] = 10 where [value] = 25 END SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[trg_Trig2] ON [dbo].[TestTable] AFTER INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for trigger here insert into log_TestTable (id, description, [value]) select tt.id, tt.description, tt.[value] from inserted i LEFT JOIN TestTable tt ON tt.id = i.id END
I think your second trigger needs to use the values from the actual table, not the inserted/deleted tables to populate the log table - inserted/deleted will always have the unaltered, original values, while your altered values will appear in the table. Make the second trigger an "After" trigger, so you will not have to use the sp_settriggerorder. Like this, for example:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[trg_Trig1] ON [dbo].[TestTable] FOR INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; update TestTable set [value] = 10 where [value] = 25 END SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[trg_Trig2] ON [dbo].[TestTable] AFTER INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for trigger here insert into log_TestTable (id, description, [value]) select tt.id, tt.description, tt.[value] from inserted i LEFT JOIN TestTable tt ON tt.id = i.id END
相关问答
更多-
我认为你的第二个触发器需要使用实际表中的值,而不是插入/删除的表来填充日志表 - 插入/删除将始终具有未更改的原始值,而更改的值将显示在表中。 使第二个触发器成为“After”触发器,因此您不必使用sp_settriggerorder。 像这样,例如: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[trg_Trig1] ON [dbo].[TestTable] FOR INSERT AS BE ...
-
你的google-fu弱我的朋友: http : //dev.mysql.com/doc/refman/5.0/en/create-trigger.html但你最终会学到:) 虽然如果这不是一个专门用于创建触发器的项目,但我不建议使用它们。 由于这个“将自动将此更改记录到另一个名为”的表,肯定可以在业务逻辑中完成。 然后,您可以控制从软件和用户完成的操作。 也许在不久的将来,您需要在表上执行datafix - 然后您必须禁用触发器,执行修复并再次启用它。 这似乎是你真的不想做的很多工作。 因此,如果可能的话 ...
-
触发更新插入(Triggers update insert)[2023-08-08]
表中的行(物理上在数据库中)的顺序由聚簇索引决定。 把它放在name_software列上,就是这样。 但 1)你真的不需要像这样对表格中的数据进行排序。 它是一个数据库...... :)您可以通过查询对其进行排序。 2)聚集索引通常在主键上,当然只能在表上有一个... The order of rows in a table (physically in the database) is decided by a clustered index. Put one on the name_software ... -
对于案例1 ,如果重复检测未找到任何重复项,则不应执行插入,正常插入将执行此操作 CREATE TRIGGER `trig_no_dup` BEFORE INSERT ON `Demo` FOR EACH ROW BEGIN SET @Counter = (SELECT COUNT(*) FROM `Demo` WHERE `StoreID` = NEW.StoreID AND `Code` = NEW.Code AND `Status` = 'Active'); - ...
-
after insert需要触发器 delimiter // create trigger total_sum after insert on meter5 for each row begin insert into hourly (id,vrms,irms,total) values (new.id,new.vrms,new.irms,new.vrms*new.irms); end ; // delimiter ; You need the trigger to be after insert so ...
-
感谢e4c5。 最佳解决方案是创建VIEW: CREATE TABLE IF NOT EXISTS `table2` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `t2col1` int(11) DEFAULT 0, `t2col2` int(11) DEFAULT 0, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; INSERT INTO `tab ...
-
是的,你不能这样做。 Mysql就是这种方式可以防止循环循环和内存问题...就像更新正在解析的游标一样:某些引擎允许它,其他引擎则不行。 Yeah, you just can't do that. Mysql is this way preventing circular loops and memory issues... It is like updating a cursor being parsed: some engines allow it, others no.
-
关于触发器的帮助(Help regarding Triggers)[2022-01-22]
引用文档 : 检测触发触发器的DML操作 如果多种类型的DML操作可以触发触发器(例如,ON INSERT OR DELETE OR UPDATE OF emp),则触发器主体可以使用条件谓词INSERTING,DELETING和UPDATING来检查触发器的哪种类型的语句。 在触发器主体的代码中,您可以根据触发触发器的DML操作的类型执行代码块: IF INSERTING THEN ... END IF; IF UPDATING THEN ... END IF; Quoting the docs: De ... -
是触发事务吗?(Are triggers transaction?)[2024-04-16]
我可以通过存储过程来显示它。 这个概念是从wchiquito的答案中解脱出来的。 我相信你会发现这是一个更详尽的答案。 这只是一个例子。 根据您的特定需求(其他触发器类型)等进行必要的更改。如何执行mysql触发器信号在不使用存储过程之外触发是任何人的猜测。 因此,如果您不愿意或无法执行存储过程, 请不要继续阅读 。 请注意,为方便起见,我们会留下任何掉落或截断的内容。 架构 create database trigTranTest; -- creates a separate database for ... -
SELECT上的触发器(Fire triggers on SELECT)[2023-01-17]
我知道只有两种方法可以做到这一点而且都没有触发。 您可以使用存储过程来运行查询,并将查询记录到表中以及您想要了解的其他信息。 您可以使用SQL Server的审核功能 。 我从来没有使用过后者,所以我不能说易用性。 There are only two ways I know that you can do this and neither are trigger. You can use a stored procedure to run the query and log the query to a ...