Ind*_*dra 0 php mysql sql-parser
我已经检查了很多,但我无法理解它.
我需要将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;:-)
Run Code Online (Sandbox Code Playgroud)
我需要做的是分别获取每个查询.问题是,如果我拆分文件,;它也将拆分包含的字符串;,而不仅仅是那些结尾的字符串;.
像这部分:a:1:{s:15:\"ActivityUserIDs\";a:2:{i:0;s:1:\"2\";i:1;s:1:\"1\";}}.我不想让它分开.
我试图与这两个preg_match()和preg_split(),但我不能得到期望的结果.
我尝试了这个模式:/[\;]+/以及其他多个模式,但我无法让它工作.
我也试图替换; 在**周围没有' 然后爆炸它,但仍然没有结果.
谢谢.