記錄一下工作中遇到的一些高級的操作

mysql

1.需求是統計羣組信息,但是羣名等信息和羣成員的信息不在同一個表裏面。這個時候的sql查詢
關注的點:
1.1.時間戳轉化成datetime 用方法from_unixtime
1.2.子查詢可以直接作爲一個參數

select a.group_id as '羣id', b.group_name as '羣組名稱',from_unixtime(b.ctime) as '創建時間', count(*) as '人數', (select user_group_name from user_group as c where admin_level = 10 and c.group_id = a.group_id limit 1) as '羣主用戶名' from user_group as a LEFT JOIN groups as b on a.group_id = b.id where b.group_type = 1 group by a.group_id order by a.group_id desc;

2.mysql在linux環境下直接執行並輸出到對應目錄

mysql -u賬號 -p密碼 -e"select code from user_login where language = 'zh-CN" 數據庫名> /data/www/html/zh-CN-code.txt

3.修改字段

alter table groups add `group_cate` tinyint(4) DEFAULT '0' COMMENT '0是私有羣 1是公開羣',

linux

1.查詢這個目錄下,所有文件夾的文件大小

du -h --max-depth=1

2.按名字查找

find / -name "文件名"

3.vim的操作
shift + D 後面全刪
dw 刪除後面的單詞

4.抓包命令

tcpdump port 9200 -i any 

5.grep支持正則匹配
用-E然後|來致辭正則匹配

 cat   /data/logs/log.log|grep recv_from | grep -E "(1021432|1001394) ->" 

6.awk 分隔和sort -u來去重

redis

1.需要在linux環境下觀察一個key的使用情況

    watch -n 1 redis-cli llen cache_data_key

php

  1. php的以爲符號,可以用於權限判斷
|| substr(decbin(FunctionHelper::getMultiOnlineStatus($msg_arr['rcode']) >> 1), -1) == 1

Yii2

1.ip的庫的下載和實現

'ip2location' => [
            'class' => '\client\components\IP2Location\Geolocation',
            'database' => '/data/www/html/httpserver/vendor/ip2location/ip2location-php/databases/IP2LOCATION-LITE-DB1.BIN',
            'mode' => 'FILE_IO',
        ],

2.批量刪除redis key
…,然後$del_cmd_ids 是數組

Yii::$app->redisMessage->srem($cmd_key, ...$del_cmd_ids);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章