$str = '/public_html/reviews/index.php';
var_export(pathinfo($str));
shell> mysqldump db_name > backup-file.sql
shell> mysql db_name < backup-file.sql
if( empty($errors))
{
//добавить коментарий
$stmt = $connection->prepare("INSERT INTO `comments` (`author`,`email`,`text`,`pubdate`,`articles_id`) VALUES (?, ?, ?, NOW(), ?)");
$stmt->bind_param("sssi", $_POST['author'], $_POST['email'], $_POST['text'], $art['id']);
$stmt->execute();
echo '<span style ="color:green;font-weight: bold;margin-bottom: 10px;display: block;">Коментарий успешно добавлен!</span>';
}
SELECT
`id_user`,
SUM(IF(`balance_history`.`date` >= NOW() - INTERVAL 1 DAY, `sum`, 0)) `sum_24h`,
SUM(`sum`) `sum_1mnth`,
`users`.`name`
FROM `balance_history`
INNER JOIN `users` ON `id_user` = users.id
WHERE `balance_history`.`date` >= NOW() - INTERVAL 1 MONTH AND `type` = 'plus'
GROUP BY `id_user`
ORDER BY `sum` DESC
LIMIT 5;
<?php
//random integer between 0 and 10
$r = rand(0,10);
// array of 10 values
$values = [
3123424,
5645654,
4545666,
4534564,
6756765,
1223423,
2343245,
1335456,
9864563,
8764508
];
//random value from array
$variable = $values[$r];
echo 'random: ' . $r . ' variable: ' .$variable;
create table genres (
id int primary key auto_increment,
name varchar(255)
);
create table films (
id int primary key auto_increment,
name varchar(255)
);
create table film_genres (
film_id int,
genre_id int
);
select g.id, g.name, count(distinct price)
from goods g
join prices p on g.id = p.id_goods
where price in (200, 205) -- prices that we need to search
group by g.id, g.name
having count(distinct price) = 2; -- 2 count different prices
update test
set html = replace(
html,
substr(
html,
locate('<nav>', html, 1) + 5,
locate('</nav>', html, locate('<nav>', html, 1))-locate('<nav>', html, 1) - 5
), '');
select class
from students
group by class
having count(*)*5 = sum(rang);
select
locate('<h4 class="notify__title notify__title--small">', html, 1) as o,
locate('</h4>', html, locate('<h4 class="notify__title notify__title--small">', html, 1)) as c,
concat('<span>',
substr(
html,
locate('<h4 class="notify__title notify__title--small">', html, 1) + 47,
locate('</h4>', html, locate('<h4 class="notify__title notify__title--small">', html, 1))-locate('<h4 class="notify__title notify__title--small">', html, 1) - 47
), '</span>') as new_html
from test;
$query = "
SELECT
materials.*
FROM materials
JOIN (
SELECT material_group, MIN(price) chipest_price
FROM materials
GROUP BY material_group
) chipest ON
chipest.material_group = materials.material_group AND
chipest_price = price;";
$stmt = $pdo->prepare($query);
$stmt->execute();
$rows = $stmt->fetchALL(PDO::FETCH_ASSOC);
var_export($rows);
$stmt = $mysqli->prepare('INSERT INTO viber_messages (`datetimemsg`, `id_viber`, `message`) VALUES (?, ?, ?);');
$stmt->bind_param('sss', $datetimemsg, $sender_id, $message);
$stmt->execute();