in workshop/99_Miscellaneous/Refactoring/functions/database.php [98:130]
function create_homepage($databaseConnection)
{
$homepageId = 1;
$homepageTitle = 'Home';
$homepageContents = '<ol class="round">
<li class="one">
<h5>Login as admin </h5>
The site admin username and password are both "admin".
</li>
<li class="two">
<h5>Customize your site</h5>
After you login, you can add, delete, and modify web pages.
</li>
<li class="asterisk">
<div class="visit">
To learn more about PhpStorm, visit <a href="http://www.jetbrains.com/phpstorm" title="PhpStorm website">jetbrains.com/phpstorm</a>.
</div>
</li>
</ol>';
$query_check_homepage_exists = "SELECT id FROM pages WHERE id = ? LIMIT 1";
$statement_check_homepage_exists = $databaseConnection->prepare($query_check_homepage_exists);
$statement_check_homepage_exists->bind_param('d', $homepageId);
$statement_check_homepage_exists->execute();
$statement_check_homepage_exists->store_result();
if ($statement_check_homepage_exists->num_rows == 0) {
$query_insert_page = "INSERT INTO pages (id, menulabel, content) VALUES (?, ?, ?)";
$statement_insert_page = $databaseConnection->prepare($query_insert_page);
$statement_insert_page->bind_param('dss', $homepageId, $homepageTitle, $homepageContents);
$statement_insert_page->execute();
$statement_insert_page->store_result();
}
}