This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.jetbrains.com/help/phpstorm/2017.1/configuring-xdebug.html | |
[Xdebug] | |
zend_extension="<path to php_xdebug.dll>" | |
xdebug.remote_enable=1 | |
xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000) | |
xdebug.profiler_enable=1 | |
xdebug.profiler_output_dir="<AMP home\tmp>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://toster.ru/q/276441 | |
Отсюда, есть и другие рекомендации от др авторов. | |
Я когда делаю Code Review критерии следующие: | |
* Безопасность: | |
- Каждый аргумент метода простого типа должен проверяться на тип в случае его проксирования и на граничные значения в случае обработки. Чуть что не так - бросается исключение. Если метод с кучкой аргументов на 80% состоит из поверки из аргументов - это вполне норм)) | |
- Никаких trigger_error, только исключения. | |
- Исключения ДОЛЖНЫ быть человеко-понятны, всякие "Something went wrong" можно отдавать пользователю, но в лог должно попасть исключение со стектрейсом и человеко-понятным описанием, что же там пошло не так. | |
- Каждый аргумент (объект) метода должен быть с тайпхинтингом на этот его класс, или интерфейс. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$str = 'the result inside big string'; | |
preg_match("/(?<=the )(.*)(?= inside)/", $str, $result_arr); | |
echo $result_arr[0]; // result | |
/* | |
(?<=) - с чего начинается искомая строка | |
(?=) - чем заканчивается искомая строка | |
(.*) - искомая строка содержит любое количество любых символов | |
PS: хороший конструктор регулярных выражений - http://www.phpliveregex.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
target="_blank" rel="noopener noreferrer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @var Получаем текущее время в миллисекундах и случайное число | |
* и хэшируем полученную строку | |
* | |
*/ | |
$hashe = md5( microtime() . mt_rand() ); | |
# Выводим хэш |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://stackoverflow.com/questions/1746213/how-to-delete-duplicate-entries | |
-- Given table table, want to unique it on (field1, field2) keeping the row with the max field3: | |
DELETE FROM table USING table alias | |
WHERE table.field1 = alias.field1 AND table.field2 = alias.field2 AND | |
table.max_field < alias.max_field | |
-- For example, I have a table, user_accounts, and I want to add a unique constraint on email, but I have some duplicates. Say also that I want to keep the most recently created one (max id among duplicates). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--example 1 | |
INSERT INTO cheap_books (id, note) | |
SELECT id, 'Was in use' | |
FROM Books WHERE id > (SELECT MAX(id) FROM Books) - 3 | |
--example2 | |
INSERT INTO public.table1 (id_user, id_operator, status) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE table2 AS SELECT * FROM table1 WHERE 1=2; | |
(This creates the structure only -- no data will be transferred because | |
1 will never equal 2). :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COUNT(X) - количество величин аргумента Х, со значением не равным NULL | |
SUM(X) - сумма величин в аргументе Х | |
MIN(X) - минимум Х | |
MAX(X) - возвращает максимум Х | |
ROUND(X) - возвращает Х округленный до ближайшего целого | |
RANDOM() - возвращает случайную величину от 0 до 1 | |
LENGTH(X) - длина строки Х | |
TRIM(X) - удаляет пробелы в начале и конце строки | |
LOWER(X) - приводит строку к нижн регистру |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psql создан как «консольное приложение». Поскольку в Windows консольные окна используют | |
кодировку символов отличную от той, что используется для остальной системы, нужно проявить | |
особую осторожность при использовании 8-битных символов. Если psql обнаружит проблемную | |
кодовую страницу консоли, он предупредит вас при запуске. Чтобы изменить кодовую страницу | |
консоли, необходимы две вещи: | |
• Задать кодовую страницу, выполнив cmd.exe /c chcp 1251. (1251 это кодовая страница для | |
России, замените на ваше значение.) При использовании Cygwin, эту команду можно записать | |
в /etc/profile. | |
• Установите консольный шрифт в Lucida Console, потому что растровый шрифт не работает с | |
кодовой страницей ANSI. |