Skip to content
Snippets Groups Projects
Commit da7a3f21 authored by Rico van Endern's avatar Rico van Endern
Browse files

minimal save to SQL no deploy

parent 2da3a09a
Branches
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ include 'helper.php'; ...@@ -4,6 +4,7 @@ include 'helper.php';
include 'gericht.php'; include 'gericht.php';
include 'tag.php'; include 'tag.php';
// Parse
$html = file_get_html ( 'http://www.stwdo.de/gastronomie/speiseplaene/hauptmensa/wochenansicht-hauptmensa/' ); $html = file_get_html ( 'http://www.stwdo.de/gastronomie/speiseplaene/hauptmensa/wochenansicht-hauptmensa/' );
$montag = parsDay ( $html, "montag" ); $montag = parsDay ( $html, "montag" );
$dienstag = parsDay ( $html, "dienstag" ); $dienstag = parsDay ( $html, "dienstag" );
...@@ -18,24 +19,24 @@ $tage = array ( ...@@ -18,24 +19,24 @@ $tage = array (
$freitag $freitag
); );
/* // SAVE
* // SAVE $mysqli = new mysqli ( "ovanier.de", "info_writer", "XAHQTZeGbqsnt8K6", "infoscreen" );
* $mysqli = new mysqli ( "ovanier.de", "info_writer", "XAHQTZeGbqsnt8K6", "infoscreen" );
* if ($mysqli->connect_errno) {
* if ($mysqli->connect_errno) { printf ( "Connect failed: %s\n", $mysqli->connect_error );
* printf ( "Connect failed: %s\n", $mysqli->connect_error ); exit ();
* exit (); }
* }
* $stmt = mysqli_prepare ( $mysqli, "INSERT INTO gerichte (originalText,shortText,rind,schwein,gefluegel,fisch,vegetarisch,vegan,kinderteller,image,date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" );
* $stmt = mysqli_prepare ( $mysqli, "INSERT INTO gerichte (originalText,shortText,rind,schwein,gefluegel,fisch,vegetarisch,vegan,kinderteller,image,date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); foreach ( $tage as $tag ) {
* foreach ( $gerichte as $gericht ) { foreach ( $tag->gerichte as $gericht ) {
* mysqli_stmt_bind_param ( $stmt, "ssiiiiiiisi", $gericht->getOriginalText (), $gericht->getShortText (), $gericht->isRind (), $gericht->isSchwein (), $gericht->isGefluegel (), $gericht->isFisch (), $gericht->isVegetarisch (), $gericht->isVegan (), $gericht->isKinderteller (), $gericht->getImage (), $gericht->getDate () ); mysqli_stmt_bind_param ( $stmt, "ssiiiiiiisi", $gericht->getOriginalText (), $gericht->getShortText (), $gericht->isRind (), $gericht->isSchwein (), $gericht->isGefluegel (), $gericht->isFisch (), $gericht->isVegetarisch (), $gericht->isVegan (), $gericht->isKinderteller (), $gericht->getImage (), $gericht->getDate () );
* $stmt->execute (); $stmt->execute ();
* } }
* $stmt->close (); }
* $stmt->close ();
* $mysqli->close ();
*/ $mysqli->close ();
// CREATE JSON // CREATE JSON
toJson ( $tage ); toJson ( $tage );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment