<?php

/* Tabellenprefix */
$prefix = 'svjf_';

/* Array mit NavIds */
$nav_ids = array();

define('PATH_ROOT', '../');
include_once(PATH_ROOT . '.config/config_global.php');

$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$db->set_charset('utf8');

$r_navi = $db->query
(
	'SELECT
						*
					FROM
						' . $prefix . TBL_NAVI . '
					WHERE
						' . $prefix . 'specialType = "content";'
);

while ($navi = $r_navi->fetch_assoc())
{
	$r_content = $db->query
	(
		'SELECT
									*
								FROM
									' . $prefix . TBL_CONTENT . '
								WHERE
									siteId = "' . $navi[$prefix . 'navId'] . '";'
	);

	if ($r_content->num_rows === 0)
	{
		$head = $db->query
		(
			'INSERT INTO
										' . $prefix . TBL_HEAD . '
										( content )
									VALUES
										( "' . $navi[$prefix . 'navName'] . '" );'
		);
		$h_id = $db->insert_id;
		$text = $db->query
		(
			'INSERT INTO
										' . $prefix . TBL_TEXT . '
										( content )
									VALUES
										( "Hier fehlt ein sinnvoller neuer Text" );'
		);
		$t_id = $db->insert_id;

		$cont = $db->query
		(
			'INSERT INTO
										' . $prefix . TBL_CONTENT . '
										( siteId , siteContents )
									VALUES
										( "' . $navi[$prefix . 'navId'] . '" , "headline_' . $h_id . ';text_' . $t_id . '" );'
		);
	}
}