function create_word(string $str, int $cnt): string
{
$len = \strlen($str);
if ($len === 0 || $cnt === 0) {
return '';
}
$result = '';
while ($cnt > $len) {
$i = ($cnt % ($len)) ?: $len;
$result = $str[$i - 1] . $result;
$cnt = ($cnt - $i) / $len;
}
$result = $str[$cnt - 1] . $result;
return $result;
}
echo create_word('abc', 9); //'bc'
echo create_word('abc', 18); //'abc'
SELECT *
FROM `car`
WHERE `status` = '1' AND
NOT EXISTS (
SELECT 1
FROM `event`
WHERE `id_car` = `car`.`id` AND (
'01.03.2019 15:40:00' BETWEEN `date_start` AND `date_end` OR
'01.03.2019 18:30:00' BETWEEN `date_start` AND `date_end` OR
('01.03.2019 15:40:00' < `date_start` AND '01.03.2019 18:30:00' > `date_end`)
)
)
SELECT @n:=@n+1 AS nn, u.*
FROM users u JOIN (SELECT @n:=0)
ORDER BY u.rating DESC
LIMIT 10
SELECT * FROM users ORDER BY rating DESC LIMIT 5, 1
SELECT * FROM table t WHERE active = 1 AND NOT EXISTS (
SELECT 1 FROM table WHERE active = 1 AND num > t.num
)
ini_set('memory_limit', '512M');
mustache:
globals:
foo: 'bar'
...
template_class_prefix: '__Mustache_'
template_base_class: 'Mustache_Template'
cache: '%kernel.cache_dir%/mustache'
loader_id: 'mustache.loader'
partials_loader_id: 'mustache.loader'
charset: '%kernel.charset%'
SELECT `id1`, `id2`, `id3`, COUNT(*) AS `count`, `p2`
FROM `table`
GROUP BY `id1`, `id2`, `id3`, `p2`
ORDER BY NULL
$stmt = $conn->executeQuery(
"SELECT * FROM users WHERE name = :name OR username = :name",
[":name" => $name]
);
//получаем список работ для пользователя user
$currentJobs = shell_exec("crontab -u user -l");
//вносим нужные изменения в расписание работ
...
//сохраняем все во временном файле
$filename = tempnam(sys_get_temp_dir(), 'crontab');
file_put_contents($filename, $currentJobs);
//обновляем cron
exec("crontab -u user " . $filename);
$SoapClient1C = new SoapClient("http://test.1c/WEB/ws/webservice?wsdl");
$List = $SoapClient1C->getDDSFact(array("BDate" => '2000-01-01', "EDate" => '2014-12-12'));