我檢查了很多,但我無法得到它的一個竅門。拆分字符串by;
我需要將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()
,但是我無法得到想要的結果。
我試過這種模式:/[\;]+/
和其他多個模式,但我不能得到它的工作。
我也試過替換;在那裏沒有''與**,然後爆炸它,但仍然沒有結果。
謝謝。
你只感興趣的';'前述換行符。由此分割? (除了最後一行中的笑臉) – ZeissS
https://www.google.de/search?q=php+sql+parser – GhostGambler
爲什麼不嘗試分割爲'),' –