Introducing a PHP library for that is compatible with Sean Forman’s Baseball Databank database or Sean Lahman’s Baseball Database. This is still in beta.

Download the library from gibhub: Baseball Tools and please consult the readme.

Installation:

  • Explode package to your local machine.
  • Fill out the necessary database information in /baseball-tools/lib/lib.php.
  • Upload the folder /baseball-tools/ which includes your updated lib.php file into your web project.
  • Include the package’s “class-baseball-tools-player.php”
  • You’re done!

Usage:

Instantiate object like such:
$bb=new Baseball_tools_player($player_id);
for example, if we were to use Ike Davis who’s player ID is davisik01 we would issue the following:
$bb=new Baseball_tools_player(“davisik01″);

Call the associated method containing which you want to access, for example if we want Ike’s age we would call $bb->get_age(); and it would return his current age.

More documentation is to come, for now a function/method list is as follows: (see code comments for instructions on their usage)

  • get_age ()
  • get_bats ()
  • get_bbref_id ()
  • get_birthday ()
  • get_birthplace ()
  • get_college ()
  • get_deathday ()
  • get_deathplace ()
  • get_given_name ()
  • get_height_feet ()
  • get_height_inches ()
  • get_hof_id ()
  • get_holtz_id ()
  • get_lahman_id ()
  • get_lahman_4_0_id ()
  • get_lahman_4_5_id ()
  • get_manager_id ()
  • get_name ()
  • get_name_note ()
  • get_nick_name ()
  • get_player_type ()
  • get_retro_id ()
  • get_stats ($year [optional])
  • get_throws ()
  • get_weight ()

Download the library from gibhub: Baseball Tools and please consult the readme.


Leave a Comment