本文整理汇总了PHP中SQL::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::getConnection方法的具体用法?PHP SQL::getConnection怎么用?PHP SQL::getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::getConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStartables
public static function getStartables()
{
if (is_null(self::$startables) || !is_array(self::$startables)) {
self::$startables = array();
QueryBuilder::create(SQL::getConnection())->withQuery("SELECT id, display_name, folder_name, executable FROM websites")->build()->forEachResult(function ($row) {
self::$startables[] = new Startables($row['id'], $row['display_name'], $row['folder_name'], $row['executable']);
});
if (count(self::$startables) == 0) {
throw new Exception("lol");
}
}
return self::$startables;
}
示例2: header
<?php
include_once "SQL.php";
if (!isset($_GET['username'], $_GET['token'])) {
header('Location: index.php');
exit;
}
$myUsername = $_GET['username'];
$mailToken = $_GET['token'];
$action = "reset_password.php?token={$mailToken}&username={$myUsername}";
if (isset($_POST['newPassword'], $_POST['confirmPassword'])) {
if ($_POST['newPassword'] !== $_POST['confirmPassword']) {
header("Location: {$action}");
exit;
}
$sql = SQL::getConnection();
$saltedPassword = $myUsername . strlen($myUsername) . $_POST['newPassword'];
$hashedPassword = hash("sha512", $saltedPassword);
$sql->query("UPDATE accounts SET password = '{$hashedPassword}', token = NULL WHERE token = '{$mailToken}' AND username = '{$myUsername}'");
if ($sql->affected_rows == 1) {
echo 'Password successfully reset!';
} else {
echo 'Invalid token.';
}
}
?>
<style type="text/css">
.shit {
width: 300px;
text-align: center;
background-color: #CCC;
示例3: ini_set
<?php
ini_set('display_errors', 'On');
spl_autoload_register(function ($className) {
// Normal PHP path
$path = $_SERVER['DOCUMENT_ROOT'] . "/php/" . $className . ".php";
if (file_exists($path)) {
/** @noinspection PhpIncludeInspection */
include_once $path;
}
});
if (!Security::hasPermission()) {
echo ":(";
die;
}
SQL::getConnection();
示例4: foreach
if ($webId == "-1") {
// Update all
foreach (Website::getAllWebsites() as $site) {
echoSite($site);
}
} else {
// Update single site
QueryBuilder::create(SQL::getConnection())->withQuery("SELECT display_name, folder_name FROM websites WHERE id = ?")->withParam($webId, QueryBuilder::PARAM_TYPE_INT)->build()->forEachResult(function ($row) {
$site = new Website(0, $row['display_name'], $row['folder_name']);
echoSite($site);
});
}
} else {
function echoStart(Startables $starter)
{
echo $starter->getName() . ":\r\n";
echo $starter->start() . "\r\n";
}
$webId = $_GET['start-id'];
/*if ($webId == "-1") {
// Update all
foreach (Website::getAllWebsites() as $site) {
echoSite($site);
}
} else {*/
// Update single site
QueryBuilder::create(SQL::getConnection())->withQuery("SELECT display_name, folder_name, executable FROM websites WHERE id = ?")->withParam($webId, QueryBuilder::PARAM_TYPE_INT)->build()->forEachResult(function ($row) {
$starter = new Startables(0, $row['display_name'], $row['folder_name']);
echoStart($starter);
});
}