change to SQL
This commit is contained in:
parent
59eb7aa3ae
commit
d044804cbb
|
@ -29,11 +29,15 @@ if ($conn->connect_error) {
|
|||
function saveToDatabase($contentArray, $conn) {
|
||||
echo "sending Query to Database<br>";
|
||||
// $sql = "INSERT INTO `topics` (`id`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ($contentArray[0], $contentArray[2], $contentArray[3], $contentArray[4], $contentArray[5], $contentArray[6], $contentArray[7], $contentArray[8]) ON DUPLICATE KEY UPDATE `id` = $contentArray[0]";
|
||||
$sql = "INSERT INTO `topics` (`id`, `lastSave`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ('test', 2014, '{}', 15, 10, 10, 10, 100, 10) ON DUPLICATE KEY UPDATE `id` = 'test'";
|
||||
$sql = "INSERT INTO `topics` (`id`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ('".$contentArray[0]."', '".$contentArray[2]."', ".$contentArray[3].", ".$contentArray[4].", ".$contentArray[5].", ".$contentArray[6].", ".$contentArray[7].", ".$contentArray[8].") ON DUPLICATE KEY UPDATE `id` = '".$contentArray[0]."'";
|
||||
$result = $conn->query($sql);
|
||||
echo "Query sent<br>";
|
||||
echo $result;
|
||||
return $result;
|
||||
echo "Query sent<br> Result: " . $result;
|
||||
if($result === 0) {
|
||||
$sql = "UPDATE `topics` SET `id`='".$contentArray[0]."',`lastSave`='".$contentArray[1]."',`fullJSON`='".$contentArray[2]."',`timeWatchM`='".$contentArray[3]."',`timeWatchW`='".$contentArray[4]."',`timeWatchD`='".$contentArray[5]."',`countWatchM`='".$contentArray[6]."',`countWatchW`='".$contentArray[7]."',`countWatchD`='".$contentArray[8]."' WHERE `id` = '".$contentArray[0]."'";
|
||||
$result = $conn->query($sql);
|
||||
echo "Query sent<br> Result: " . $result;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function getFromDatabase() {
|
||||
|
|
Loading…
Reference in New Issue