set @code = 1000;
update watch
join (
select id, @code := @code + 1 as code from watch
) data using (id)
set watch.code = data.code;
echo preg_replace('/<p>[^<]+</', '<p>qwe<', '<div>123</div>');
echo PHP_EOL;
echo preg_replace('/<p>[^<]+</', '<p>qwe<', '<p>123</p>');
echo PHP_EOL;
echo preg_replace('/<p>[^<]+</', '<p>qwe<', '<p>123<a href="/123">123</a></p>');
echo PHP_EOL;
select json_object(
'id', user_id,
'username', username,
'project_id', project_id,
'roles', json_arrayagg(role)
) roles
from user_projects
join users on users.id = user_id
group by user_id, project_id;
$result = mysqli_query($link, "SELECT * FROM mytable");
if ($result) {
echo "ok";
while ($row = mysqli_fetch_assoc($result)) {
print_r($row);
}
}
SELECT
GREATEST(0, -- return 0 in case negative balance
SUM(
IF(`status` = 1 AND `date_bonus_to` > NOW() , `points`, 0) -- bonus added and not expired
- IF(`status` = 2, `points`, 0) -- bonus used
)
) `balance`
FROM `ps_bonus_account`
WHERE
`id_customer` = 518 AND
`paid` = 1
GROUP BY `id_customer`;
<?php
$htmlstr = '<p><span>В связи с временными ограничениями направляем пояснительные документы к Указам правительства Москвы и МО<br />Скачать файлы вы можете в СФМ в разделе <a href="http://test.com/announce/view?id=1" target="_blank" rel="noopener">рекламные материалы.</a></span></p>';
$dom = new DOMDocument();
$dom->loadHTML($htmlstr);
$href = $dom->getElementsByTagName('a')[0]->getAttribute('href');
printf("href: %s", $href);
print_r(parse_url($href));
CREATE TABLE categories (
id int auto_increment primary key,
name varchar(64)
);
<?php
function getRightCategories($db)
{
$result = $db->query('SELECT id, name FROM categories');
return $result->fetchAll(PDO::FETCH_KEY_PAIR);
}
$categories = getRightCategories($pdo);
print_r($categories);
<?php
$htmlstr = '<script type="text/javascript" charset="utf-8" async src="https://api-maps.yandex.ru/services/constructor/1.0/js/?um=constructor%3Adb7dbcf66a9b7b9da6551f0e57faacc7d56b5eefea90c5a357479ff1bcc47211&width=100%25&height=400&lang=ru_RU&scroll=true"></script>';
$dom = new DOMDocument();
$dom->loadHTML($htmlstr);
$src = $dom->getElementsByTagName('script')[0]->getAttribute('src');
printf("Script src: %s", $src);
touch ./resources/docker/logs/slow.log
chown 777 ./resources/docker/logs/slow.log
- "./resources/docker/logs/slow.log:/var/log/mysql/mysql-slow.log"
volumes:
- "./resources/docker/config/my.cfg:/etc/mysql/conf.d/config-file.cnf"
- "./resources/docker/logs/mysql/:/var/log/mysql/"
- "./resources/schema/schema.sql:/docker-entrypoint-initdb.d/1-schema.sql"
$Subscriptions->end_date = date("Y-m-d H:i:s", strtotime($Subscriptions->end_date . " +1 month"));
$subscription->save();
$('#select_workspace').on('change', function(){
var workspace = $(this).val();
// ***********************************************
var worktype = $('#select_worktype').val();
// ***********************************************
if(workspace){
$.get(
"ajax.php",
{workspace: workspace, worktype:worktype},
function (data2){
$('#select_position').html(data2);
}
);
}else{
$('#select_position').html('<option disabled selected>Выбор формирования</option>');
}
});
/(\|\|description\|[^|]+\|\|)/
<?php
$string = 'poster|text||title|text||title_en|text||year|2020||description|тут могут быть любые символы||countries|text||genres|text|| .....';
preg_match('/(\|\|description\|[^|]+\|\|)/', $string, $matches);
var_dump($matches[1]);