select
* ,
case
when role = 'boss' then 3
when role = 'admin' then 2
else 1
end as weight
from gamers order by weight desc;
select *
from gamers
order by role = 'boss' desc, role = 'admin' desc;
$sql = 'SELECT * FROM articles WHERE id = ?';
$result = $db->prepare($sql);
$result->setFetchMode(PDO::FETCH_ASSOC);
$result->execute([$id]);
<?php
function getOne($conn) {
$result = mysqli_query($conn,"
SELECT *
FROM `stat`
JOIN `order` ON `order`.`id` = `stat`.`order_id`
WHERE `delivery`='Почта' AND `cost`='0'"
);
if (mysqli_num_rows($result)>0) {
while ($row = mysqli_fetch_assoc($result)) {
echo json_encode($row);
}
}
else {
echo "Ошибка в getOne";
}
mysqli_close($conn);
}
function addList($data, $conn)
{
$cart = json_decode($data["cart"], true);
$stmt = $conn->prepare(
"UPDATE `list` SET `count` = GREATEST(`count` - ?, 0) WHERE `id`= ? ;"
);
/* bind parameters for list */
$stmt->bind_param("ds", $count, $id);
foreach ($cart as $value) {
$id = $value["id"];
$count = $value["count"];
/* execute query */
$stmt->execute();
}
}
$login = $_POST['login'];
$hash = password_hash($_POST['password']);
$login = $_POST['login'];
$password = $_POST['password']; // не хешируем
SELECT * FROM users WHERE login = '$login'
if (password_verify($password, $hash_from_db)) {
// пользователь аутентифицирован
} else {
// пара логин/пароль неверная
}
$sql = "INSERT INTO `slider` (`title`, `description`, `link`, `type_event`, `date_select_1`, `date_select_2`, `date_select_3`, `date_select_4`, `date_cont_1`, `date_cont_2`, `date_select_1_time`, `date_select_2_time`, `date_select_3_time`, `date_select_4_time`, `date_cont_1_time`, `date_cont_2_time`, `title_en`, `description_en`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
1 + 2 == 3
1 | 2 == 3
1 + 3 == 4
1 | 3 == 3
echo(XHPROF_FLAGS_CPU);