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