このテーブルテンプレートを変換するためのphpまたはいくつかのロジックでの最良の方法は何ですか?
$tmpl="CREATE TABLE `wpsc_claimed_stock` ( `product_id` bigint(20) unsigned NOT NULL DEFAULT '0', `variation_stock_id` bigint(20) unsigned NOT NULL DEFAULT '0', `stock_claimed` float NOT NULL, `last_activity` datetime NOT NULL, `cart_id` varchar(255) NOT NULL DEFAULT '0', `cart_submitted` varchar(1) NOT NULL DEFAULT '0', UNIQUE KEY `unique_key` (`product_id`,`variation_stock_id`,`cart_id`), KEY `last_activity` (`last_activity`), KEY `cart_submitted` (`cart_submitted`) )";
注: このスニペットは wp-ecommerce (wordpress プラグイン) から取得しました
$table_name = 'wpsc_claimed_stock'; /* !wpsc_claimed_stock */ $wpsc_database_template[$table_name]['columns']['product_id'] = "bigint(20) UNSIGNED NOT NULL DEFAULT '0' "; $wpsc_database_template[$table_name]['columns']['variation_stock_id'] = "bigint(20) UNSIGNED NOT NULL DEFAULT '0' "; $wpsc_database_template[$table_name]['columns']['stock_claimed'] = "FLOAT NOT NULL "; $wpsc_database_template[$table_name]['columns']['last_activity'] = "DATETIME NOT NULL "; $wpsc_database_template[$table_name]['columns']['cart_id'] = "VARCHAR( 255 ) NOT NULL DEFAULT '0' "; $wpsc_database_template[$table_name]['columns']['cart_submitted'] = "VARCHAR( 1 ) NOT NULL DEFAULT '0' "; $wpsc_database_template[$table_name]['indexes']['unique_key'] = "UNIQUE KEY `unique_key` ( `product_id`,`variation_stock_id`,`cart_id`)"; $wpsc_database_template[$table_name]['indexes']['last_activity'] = "KEY `last_activity` ( `last_activity` )"; $wpsc_database_template[$table_name]['indexes']['cart_submitted'] = "KEY `cart_submitted` ( `cart_submitted` )";