SELECT * FROM polzovateli_statistica ps
WHERE NOT EXISTS (
SELECT 1 FROM polzovateli_statistica WHERE uid = ps.uid AND started > ps.started
)
SELECT u.*, t2.date FROM users u LEFT JOIN (
SELECT @rn := IF(t1.prevdate IS NULL, 1, @rn + 1) rn, t1.id, t1.user_id, t1.date FROM (
SELECT o.id, o.user_id, o.date, o2.date prevdate
FROM orders o
LEFT JOIN orders o2 ON o2.user_id = o.user_id AND o2.date < o.date
LEFT JOIN orders o3 ON o3.user_id = o.user_id AND o3.date > o2.date AND o3.date < o.date
WHERE o3.id IS NULL ORDER BY o.user_id, o.date
) t1, (SELECT @rn := 0) sg
) t2 ON t2.user_id = u.id AND t2.rn = 2
class MySQL
{
public function connect ()
{
//code
}
}
class Page
{
protected $_mySql;
//можно передавать экземпляр класса MySQL в конструктор класса Page
public function __construct(MySQL $mySql = null)
{
$this->_mySql = $mySql;
}
// а можно создать для этого отдельный метод
public function setMySql(MySQL $mySql)
{
$this->_mySql = $mySql;
}
public function func ()
{
$this->_mySql->Connect();
//code
}
}
$mySql = new MySQL;
$page1 = new Page($mySql);
$page2 = new Page();
$page2->setMySql($mySql);
$page1->func();
$page2->func();
SELECT CONV(hash, 16, 10) ^ 0xd9d8266fd990160e FROM table
SELECT DISTINCT IF(sender_id > recipient_id, sender_id, recipient_id) id1, IF(sender_id < recipient_id, sender_id, recipient_id) id2 FROM dialog
ALTER TABLE geo_fias_addrobj ADD INDEX (parentguid, aolevel, formalname)
SELECT SQL_NO_CACHE * FROM `geo_fias_addrobj`
WHERE `geo_fias_addrobj`.`parentguid` = '0c5b2444-70a0-4932-980c-b4dc0d3f02b5'
AND `geo_fias_addrobj`.`aolevel` = 7
AND formalname LIKE 'Гру%'
AND `geo_fias_addrobj`.`actstatus` = 1
AND `geo_fias_addrobj`.`shortname` IN ('аллея', 'б-р', 'въезд', 'заезд', 'кв-л', 'кольцо', 'линия', 'наб', 'остров', 'парк', 'пер', 'пл', 'проезд', 'пр-кт', 'проулок', 'сквер', 'тракт', 'туп', 'ул', 'уч-к', 'ш', 'аул', 'городок', 'д', 'вал')
LIMIT 10
UPDATE product SET disabled = 1 WHERE id IN (
SELECT product.id FROM product LEFT JOIN product_image ON product.id = product_image.product_id GROUP BY product.id HAVING COUNT(product_image.id) = 0);
UPDATE product SET disabled = 1 WHERE NOT EXISTS (SELECT 1 FROM product_image WHERE product_id = product.id)
error_page 500 502 503 504 /50x.html;
server {
listen *:80; # port http
set $https off;
location / {
proxy_pass http://dutybalancer;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen *:443 ssl; # port https
set $https on;
... тут немного сертификатов
location / {
proxy_pass https://dutybalancer_ssl;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}