Revision: 54297
Updated Code
at December 19, 2011 07:47 by wa-rufio
Updated Code
<?php $uname = ''; $pswrd = ''; $con = mysql_connect("localhost",$uname,$pswrd); if (!$con) { die('Could not connect: ' . mysql_error()); } $db = "CREATE DATABASE IF NOT EXISTS pitchfx"; mysql_query($db,$con) or die('Error while running query ' . mysql_error()); mysql_select_db('pitchfx',$con) or die('Error while selecting database. ') . mysql_error()); $sql = "CREATE TABLE IF NOT EXISTS `pitches` ( `inning` tinyint(4) NOT NULL, `date_id` varchar(30) NOT NULL, `top_bot` tinyint(1) NOT NULL, `away` varchar(3) NOT NULL, `home` varchar(3) NOT NULL, `pitch_id` mediumint(8) unsigned NOT NULL, `pitch_hand` varchar(1) NOT NULL, `ab_id` mediumint(8) unsigned NOT NULL, `ab_hand` varchar(1) NOT NULL, `des` varchar(55) NOT NULL, `type` varchar(1) NOT NULL, `id` smallint(5) unsigned NOT NULL, `x` float unsigned NOT NULL, `y` float unsigned NOT NULL, `start_speed` float unsigned DEFAULT NULL, `end_speed` float unsigned DEFAULT NULL, `sz_top` float unsigned DEFAULT NULL, `sz_bot` float unsigned DEFAULT NULL, `pfx_x` float DEFAULT NULL, `pfx_z` float DEFAULT NULL, `px` float DEFAULT NULL, `pz` float DEFAULT NULL, `x0` float DEFAULT NULL, `y0` float DEFAULT NULL, `z0` float DEFAULT NULL, `vx0` float DEFAULT NULL, `vy0` float DEFAULT NULL, `vz0` float DEFAULT NULL, `ax` float DEFAULT NULL, `ay` float DEFAULT NULL, `az` float DEFAULT NULL, `break_y` float DEFAULT NULL, `break_angle` float DEFAULT NULL, `break_length` float DEFAULT NULL, `ball` tinyint(3) unsigned DEFAULT NULL, `strike` tinyint(3) unsigned DEFAULT NULL, `on_1b` mediumint(8) unsigned DEFAULT NULL, `on_2b` mediumint(8) unsigned DEFAULT NULL, `on_3b` mediumint(8) unsigned DEFAULT NULL, `sv_id` varchar(13) DEFAULT NULL, `pitch_type` varchar(2) DEFAULT NULL, `type_confidence` double DEFAULT NULL, `zone` tinyint(2) DEFAULT NULL, `nasty` tinyint(3) unsigned DEFAULT NULL, `spin_dir` double unsigned NOT NULL, `spin_rate` double NOT NULL, `pitch_seq` varchar(55) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"; mysql_query($sql,$con) or die('Error while executing query. ' . mysql_error()); mysql_close($con); ?>
Revision: 54296
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 19, 2011 07:34 by wa-rufio
Initial Code
<?php $uname = ''; $pswrd = ''; $con = mysql_connect("localhost",$uname,$pswrd); if (!$con) { die('Could not connect: ' . mysql_error()); } $db = "CREATE DATABASE IF NOT EXISTS pitchfx"; mysql_query($db,$con) or die('Error while running query ') . mysql_error()); mysql_select_db('pitchfx',$con) or die('Error while selecting database. ') . mysql_error()); $sql = "CREATE TABLE IF NOT EXISTS `pitches` ( `inning` tinyint(4) NOT NULL, `date_id` varchar(30) NOT NULL, `top_bot` tinyint(1) NOT NULL, `away` varchar(3) NOT NULL, `home` varchar(3) NOT NULL, `pitch_id` mediumint(8) unsigned NOT NULL, `pitch_hand` varchar(1) NOT NULL, `ab_id` mediumint(8) unsigned NOT NULL, `ab_hand` varchar(1) NOT NULL, `des` varchar(55) NOT NULL, `type` varchar(1) NOT NULL, `id` smallint(5) unsigned NOT NULL, `x` float unsigned NOT NULL, `y` float unsigned NOT NULL, `start_speed` float unsigned DEFAULT NULL, `end_speed` float unsigned DEFAULT NULL, `sz_top` float unsigned DEFAULT NULL, `sz_bot` float unsigned DEFAULT NULL, `pfx_x` float DEFAULT NULL, `pfx_z` float DEFAULT NULL, `px` float DEFAULT NULL, `pz` float DEFAULT NULL, `x0` float DEFAULT NULL, `y0` float DEFAULT NULL, `z0` float DEFAULT NULL, `vx0` float DEFAULT NULL, `vy0` float DEFAULT NULL, `vz0` float DEFAULT NULL, `ax` float DEFAULT NULL, `ay` float DEFAULT NULL, `az` float DEFAULT NULL, `break_y` float DEFAULT NULL, `break_angle` float DEFAULT NULL, `break_length` float DEFAULT NULL, `ball` tinyint(3) unsigned DEFAULT NULL, `strike` tinyint(3) unsigned DEFAULT NULL, `on_1b` mediumint(8) unsigned DEFAULT NULL, `on_2b` mediumint(8) unsigned DEFAULT NULL, `on_3b` mediumint(8) unsigned DEFAULT NULL, `sv_id` varchar(13) DEFAULT NULL, `pitch_type` varchar(2) DEFAULT NULL, `type_confidence` double DEFAULT NULL, `zone` tinyint(2) DEFAULT NULL, `nasty` tinyint(3) unsigned DEFAULT NULL, `spin_dir` double unsigned NOT NULL, `spin_rate` double NOT NULL, `pitch_seq` varchar(55) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"; mysql_query($sql,$con) or die('Error while executing query. ' . mysql_error()); mysql_close($con); ?>
Initial URL
Initial Description
Creates table structure for pitchfx data that is provided by mlb.com. Open PHP file and enter username and password for localhost. Feel free to customize to suit your preference.
Initial Title
PHP Create pitchfx Table Structure
Initial Tags
mysql, php, table
Initial Language
PHP