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
# Поиск дубликатов | |
# Подсчет дублей | |
SELECT `col1`, COUNT(`col1`) AS `count` FROM `table` GROUP BY `col1` HAVING `count` > 1; | |
# Подсчет дубликатов по нескольким полям | |
SELECT `col1`, `col2`, COUNT(*) AS `count` FROM `table` GROUP BY `col1`,`col2` HAVING `count` > 1; | |
# Все записи с одинаковыми значениями | |
# Запрос найдет все записи с одинаковыми значениями в `col1` | |
SELECT * FROM `table` WHERE `col1` IN (SELECT `col1` FROM `table` GROUP BY `col1` HAVING COUNT(*) > 1) ORDER BY `col1`; | |
# Для одинаковых значений в `col1` и `col2` |
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
<a href="document.html" rel="ext">в новое окно</a><br /> | |
<script> | |
function externalLinks() { | |
if (!document.getElementsByTagName) return; | |
var anchors = document.getElementsByTagName("a"); | |
for (var i=0; i < anchors.length; i++) { | |
if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "ext") { | |
anchors[i].target = "_blank"; | |
} | |
} |
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
ini_set('display_errors', 'On'); // сообщения с ошибками будут показываться | |
error_reporting(E_ALL); // E_ALL - отображаем ВСЕ ошибки |
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 | |
// Информация о IP | |
/* | |
Получить информацию об IP-адресе можно с помощью сервиса WHOIS REST API, отправив запрос на http://rest.db.ripe.net/search?query-string=xxx.xxx.xxx.xxx | |
Ответ будет в формате XML. | |
*/ | |
$ip = '213.180.193.1'; | |
$xml = simplexml_load_string(file_get_contents('http://rest.db.ripe.net/search?query-string=' . $ip)); | |
$array = json_decode(json_encode($xml), TRUE); |
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
-- Временные таблицы в MySQL | |
-- Создание пустой таблицы: | |
CREATE TEMPORARY TABLE `tmp_table` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(255) NOT NULL, | |
`price` decimal(11,2) unsigned NOT NULL DEFAULT '0.00', | |
`sef` varchar(255) NOT NULL, | |
`text` text NOT NULL, | |
`approve` tinyint(1) NOT NULL DEFAULT '1', |
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 | |
// Сom_create_guid() | |
function gen_token() | |
{ | |
if (function_exists('com_create_guid') === true) { | |
return trim(com_create_guid(), '{}'); | |
} | |
return sprintf( | |
'%04X%04X-%04X-%04X-%04X-%04X%04X%04X', |
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
Абаза | |
Абакан | |
Абдулино | |
Абинск | |
Агидель | |
Агрыз | |
Адыгейск | |
Азнакаево | |
Азов | |
Ак-Довурак |
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 IF NOT EXISTS `city` ( | |
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, | |
`name` varchar(255) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; | |
INSERT INTO `city` SET `name` = 'Абаза'; | |
INSERT INTO `city` SET `name` = 'Абакан'; | |
INSERT INTO `city` SET `name` = 'Абдулино'; | |
INSERT INTO `city` SET `name` = 'Абинск'; |
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 | |
$array = array( | |
'Абаза', | |
'Абакан', | |
'Абдулино', | |
'Абинск', | |
'Агидель', | |
'Агрыз', | |
'Адыгейск', |
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 | |
// Отправка заголовков | |
$file = __DIR__ . '/file.avi'; | |
header('Content-Description: File Transfer'); | |
header('Content-Type: video/x-msvideo'); | |
header('Content-Disposition: attachment; filename=' . basename($file)); | |
header('Content-Transfer-Encoding: binary'); | |
header('Content-Length: ' . filesize($file)); |
NewerOlder