我已经检查了很多,但我无法掌握它。
我需要将 sql 转储拆分为查询。
我需要的基本上是这样的字符串:
DROP TABLE IF EXISTS `GDN_Activity`;
CREATE TABLE `GDN_Activity` (
`ActivityID` int(11) NOT NULL AUTO_INCREMENT,
`ActivityTypeID` int(11) NOT NULL,
`NotifyUserID` int(11) NOT NULL DEFAULT '0',
`ActivityUserID` int(11) DEFAULT NULL,
`RegardingUserID` int(11) DEFAULT NULL,
`Photo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`HeadlineFormat` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`Story` text COLLATE utf8_unicode_ci,
`Format` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`Route` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`RecordType` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`RecordID` int(11) DEFAULT NULL,
`InsertUserID` int(11) DEFAULT NULL,
`DateInserted` datetime NOT NULL,
`InsertIPAddress` varchar(39) COLLATE utf8_unicode_ci DEFAULT NULL,
`DateUpdated` datetime NOT NULL,
`Notified` tinyint(4) NOT NULL DEFAULT '0',
`Emailed` tinyint(4) NOT NULL DEFAULT '0',
`Data` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`ActivityID`),
KEY `IX_Activity_Notify` (`NotifyUserID`,`Notified`),
KEY `IX_Activity_Recent` (`NotifyUserID`,`DateUpdated`),
KEY `IX_Activity_Feed` (`NotifyUserID`,`ActivityUserID`,`DateUpdated`),
KEY `IX_Activity_DateUpdated` (`DateUpdated`),
KEY `FK_Activity_InsertUserID` (`InsertUserID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
LOCK TABLES `GDN_Activity` WRITE;
INSERT INTO `GDN_Activity` VALUES (1,17,-1,5,NULL,NULL,'{ActivityUserID,You} joined.','Welcome Aboard!',NULL,NULL,NULL,NULL,NULL,
'2014-04-30 08:53:43','127.0.0.1','2014-04-30 08:53:49',0,0,'a:1:{s:15:\"ActivityUserIDs\";a:2:{i:0;s:1:\"2\";i:1;s:1:\"1\";}}'),(2,15,-1,2,4,NULL,
'{RegardingUserID,you} → {ActivityUserID,you}',
'Ping! An activity post is a public way to talk at someone. When you update your status here, it posts it on your activity feed.','Html',
NULL,NULL,NULL,4,'2014-04-30 08:53:49',NULL,'2014-04-30 08:53:49',0,0,NULL),(3,15,-1,5,3,NULL,
'{RegardingUserID,you} → {ActivityUserID,you}',
'Ping! An activity post is a public way to talk at someone. When you update your status here, it posts it on your activity feed.','Html',
NULL,NULL,NULL,3,'2014-04-30 08:53:52',NULL,'2014-04-30 08:53:52',0,0,NULL);
UNLOCK TABLES;:-)
我需要做的是分别获取每个查询。问题是,如果我用它来分割文件,;
它也会分割包含 的字符串;
,而不仅仅是那些以 . 结尾的字符串;
。
喜欢这部分:a:1:{s:15:\"ActivityUserIDs\";a:2:{i:0;s:1:\"2\";i:1;s:1:\"1\";}}
。我不希望这被拆分。
我都尝试过preg_match()
和preg_split()
,但我无法得到想要的结果。
我尝试将此作为一种模式:/[\;]+/
以及围绕它的多种其他模式,但我无法让它发挥作用。
我也尝试更换;在它周围没有''的地方用**然后爆炸它,但仍然没有结果。
谢谢。