/**
	 * The main method in this class, returns the SQL for INSERTing data into a row.
	 * @param DataRow $row The row to process.
	 * @return string
	 */
	public function buildRowSql(DataRow $row)
	{
		$sql = "";
		$platform = $this->getPlatform();
		$table = $this->getTable();

		$sql .= "INSERT INTO ".$this->quoteIdentifier($this->getTable()->getName())." (";

		// add column names to SQL
		$colNames = array();
		foreach ($row->getColumnValues() as $colValue) {
			$colNames[] = $this->quoteIdentifier($colValue->getColumn()->getName());
		}

		$sql .= implode(',', $colNames);

		$sql .= ") VALUES (";

		$colVals = array();
		foreach ($row->getColumnValues() as $colValue) {
			$colVals[] = $this->getColumnValueSql($colValue);
		}

		$sql .= implode(',', $colVals);
		$sql .= ");
";

		return $sql;
	}
 function PreRender()
 {
     $style = $this->Style != '' ? " style='{$this->Style}' " : '';
     $class = $this->Class != '' ? " class='{$this->Class}' " : '';
     $tablestring = "<table " . $style . $class . ">";
     if (count($this->DataTableHeaders) > 0) {
         foreach ($this->DataTableHeaders as $key => $val) {
             $tablestring .= $val->Render();
         }
     }
     $alternate = false;
     if ($this->DataItems != null && count($this->DataItems) > 0) {
         foreach ($this->DataItems as $key => $val) {
             $class = $alternate ? $this->AlternatingClass : "";
             $dr = new DataRow($key, $val, $this->DataItemColumns, $class, '');
             $dr->SelectIdentity = $this->SelectIdentity;
             $dr->DeleteIdentity = $this->DeleteIdentity;
             $tablestring .= $dr->Render();
             $alternate = !$alternate;
         }
     }
     if (count($this->DataTableFooters) > 0) {
         foreach ($this->DataTableFooters as $key => $val) {
             $tablestring .= $val->Render();
         }
     }
     $tablestring .= "</table>";
     return $tablestring;
 }
//Parameters extracted:

N.Players, AgeAVG, N.ForeignPlayers, TeamValue_MLN€, PlayerValueAVG_MLN€
 
Needs to be executed after the tm_conversion script since it's using tm_id

//Run more than once: parse max one league per run
**/
require 'helper.php';
$leagueURL = array();
//$leagueURL[]="http://www.transfermarkt.it/serie-a/startseite/wettbewerb/IT1/plus/?saison_id=";
//$leagueURL[]="http://www.transfermarkt.it/premier-league/startseite/wettbewerb/GB1/plus/?saison_id=";
$leagueURL[] = "http://www.transfermarkt.it/primera-division/startseite/wettbewerb/ES1/plus/?saison_id=";
//$leagueURL[]="http://www.transfermarkt.it/1-bundesliga/startseite/wettbewerb/L1/plus/?saison_id=";
echo '<div class="row"><div class="col-md-6">';
$row = new DataRow();
foreach ($leagueURL as $url) {
    $league_id = setTMLeagueId($url);
    for ($year = 2010; $year <= 2015; $year++) {
        $html = file_get_html_tm($url . $year);
        echo "<b>Parsing transfermarkt stats for league={$league_id} and year={$year}</b><br>";
        //result
        $dataArray = [];
        $div = $html->find('div[id=yw1]')[0];
        foreach ($div->find('table[class=items]') as $table) {
            foreach (array_slice($table->find('tr'), 2) as $tr) {
                //echo $tr."<br>";
                $tm_id = $tr->find('a[class=vereinprofil_tooltip]', 1)->id;
                $row->getTMTeamId($conn, $tm_id);
                $row->league_id = $league_id;
                $row->year = $year;
Example #4
0
 /**
  * adds rows at the end of the DataTable
  * each row can be an array, or just a value (string or number)
  * @param array $rows 
  */
 public function addRows(array $rows)
 {
     foreach ($rows as $row) {
         $this->rows[] = DataRow::fromArray($row);
     }
 }
Example #5
0
 public function getValue(DataRow $row)
 {
     return $row->getId();
 }
error_reporting(0);
$html = file_get_html("stadiums.html");
echo '<div class="row"><div class="col-md-6">';
echo "<b>Parsing transfermarkt stadiums </b><br>";
//result
$input_id = getInputId($conn, "Stadium Capacity", "Social", 0, "number");
foreach ($html->find('table[class=items]') as $table) {
    echo "<br>New League<br>";
    foreach (array_slice($table->find('tr'), 1) as $tr) {
        foreach ($tr->find('table') as $tab) {
            $tm_id = $tab->find('a', 1)->id;
        }
        $value = $tr->find('td[class=rechts]', 0)->plaintext * 1000;
        if ($value > 0) {
            //echo "$tm_id----------$value ";
            $row = new DataRow();
            $row->getTMTeamId($conn, $tm_id);
            if ($row->team_id > 0) {
                $row->value = $value;
                $row->input_id = $input_id;
                echo $row->fixedInsertQuery() . " ";
                if ($conn->query($row->fixedInsertQuery())) {
                    $row->insertMessage("Stadium Capacity");
                }
            }
            echo "<br>";
        }
    }
}
echo '</div><div class="col-md-6">';
echo "Done Parsing<br>";