Kod
<?php
$sql = file_get_contents('source.sql');
$regex = '/CREATE TABLE IF NOT EXISTS|INSERT INTO|ALTER TABLE `[0-9a-zA-Z-_]+`/';
$matches = array();
preg_match_all($regex, $sql, $matches);
print_r($matches);
?>
SQL
CREATE TABLE IF NOT EXISTS `adminnotification_inbox` (
`notification_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`severity` tinyint(3) unsigned NOT NULL DEFAULT '0',
`date_added` datetime NOT NULL,
`title` varchar(255) NOT NULL,
`description` text,
`url` varchar(255) NOT NULL,
`is_read` tinyint(1) unsigned NOT NULL DEFAULT '0',
`is_remove` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`notification_id`),
KEY `IDX_SEVERITY` (`severity`),
KEY `IDX_IS_READ` (`is_read`),
KEY `IDX_IS_REMOVE` (`is_remove`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `admin_assert` (
`assert_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`assert_type` varchar(20) NOT NULL DEFAULT '',
`assert_data` text,
PRIMARY KEY (`assert_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ACL Asserts' AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `admin_role` (
`role_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(10) unsigned NOT NULL DEFAULT '0',
`tree_level` tinyint(3) unsigned NOT NULL DEFAULT '0',
`sort_order` tinyint(3) unsigned NOT NULL DEFAULT '0',
`role_type` char(1) NOT NULL DEFAULT '0',
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`role_name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`role_id`),
KEY `parent_id` (`parent_id`,`sort_order`),
KEY `tree_level` (`tree_level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ACL Roles' AUTO_INCREMENT=4;
INSERT INTO `admin_role` (`role_id`, `parent_id`, `tree_level`, `sort_order`, `role_type`, `user_id`, `role_name`) VALUES
(1, 0, 1, 1, 'G', 0, 'Administrators'),
(3, 1, 2, 0, 'U', 1, 'Template');
Yukarıdaki kod sadece takın ve tablolar oluşturmak, çıkış tablo adlarını görünmüyor neden anlamaya çalışıyorum ...
Çıktı
Array ([0] => Array (OLMAYAN BULUNMASI HALİNDE [1] => TABLO OLUŞTURMA BULUNMASI HALİNDE [0] => CREATE TABLE DEĞİL [3] => INSERT INTO BULUNMASI HALİNDE [2] => CREATE TABLE) [1] => Array ([0] => [1] => [2] => [3] =>))