PHP標記php
1.Xml風格<?php ?> 2.簡短風格 <? ?> 需在php.ini中開啓short_open_tag 3.asp風格 <% %> 需在php.ini中開啓asp.tags 4.腳本風格 <script language="php"></script>
PHP註釋css
1.單行註釋://,# 2.多行註釋:/* */
變量申明html
1.以$爲開頭 2.大小寫敏感
靜態變量Eample:mysql
class test { public static $constr="這是一個靜態變量"; } echo test::$constr;
全局變量linux
1.$_GET 2.$_POST 3.$_REQUEST 4.$_FILES 5.$_SESSION 使用前,需session_start(); 6.$_COOKIE 7.$_SERVER 8.$_ENV 9.$_GOLBALS
基本函數nginx
1.var_dump() //查看數據類型 2.isset() //判斷變量是否存在 3.empty() //判斷變量是否爲空 4.is_string(),is_numeric()·· //判斷相關數據類型 5.unset() //銷燬變量 6.define() //定義相關常量 7.date("Y-m-d H:i:s") //獲取系統時間 8.set_default_timezone_set("Etc/GMT-8"); //設置時間爲東八區 9.die(),exit() //終止運行 10.error_log(mysqli_connect_error(),3,"1.txt"); //記錄系統日誌
基本字符串函數web
1.字符串格式化 1).ltrim(),rtrim(),trim() //刪除空格 2).str_pad() //填充字符串 3).string_format() //格式化字符串[可用於數字格式化] 4).ucfirst(),lcfirst() //首字母大小寫 5).ucwords() //單詞首字母大寫[以逗號隔開後,不執行] 6).strtoupper(),strtolower() //轉換大小寫 7).strlen(),mb_strlen() //字符長度,前爲英文,後衛中文,utf-8下,一個漢字佔三個字符 8).strrev() //字符串反轉[中文下亂碼] 9).substr_count(),mb_substr_count() //統計詞頻 10).md5() //md5加密 2.字符串比較 1).strcmp(),strcasecmp() //比較,後者區分大小寫 3.字符串分割,截取 1).implode() //將數組拼接爲字符串 2).explode() //將字符串分割成數組,根據參數字符 3)str_split() //將字符串分割成數組,根據長度 4)substr(),mb_substr() //截取字符串,後者爲中文 5).str_replace() //替換子串 6).strstr(),stristr() //根據字符參數,截取字符串 7).strpos(),strrpos() //返回字符串第一次出現的位置 4.其餘 1.json_encode($str,JSON_UNESCAPED_UNICODE) 1.對字符串進行json編碼,支持中文,JSON_UNESCAPED_UNICODE參數使用版本PHP5.4+ 2.json_decode(); //對json數據進行解碼
數組函數sql
1.鍵值操做 1).array_values() //獲取值array() 2).array_keys() //獲取鍵array() 3).array_filp() //交換鍵值 4).array_reverse() //反轉字符 2.指針操做: 1).reset() //重置指針 2).next(),prev() //進前,退後指針 3).current() //當前指針 4).end() //最後指針 5).key() //當前鍵 3.查詢操做 1).in_array() //是否存在 2).array_values(),array_keys() 3).array_key_exists() 4.統計 1).array_count_values() //統計數組中,元素出現的頻率 2).array_unique() //數組去重 3)count() //數組長度 5)排序 1).sort(),rsort() //按值排序,丟棄原有鍵 2).ksort(),krsort() //按鍵排序 3).asort(),arsort() //按值排序,不丟棄原有鍵 6).操做 1).array_slice() //截取數組 2).array_splice() //數組替換 3).array_combine(),array_megre() //數組合並 4).array_intersect() //數組交集 5)array_diff() //取數組差集,以某一參數爲基準 7).數組回調 1).array_filter() //使用回調函數過濾數組 2).array_walk() //使用回調函數,操做數組,不改變數組值 3).array_map() //使用回調函數,操做數組,改變數組值
**文件操做shell
1.打開文件: $logfile=fopen("1.txt",'a'); 2.寫入文件: fwrite($logfile,'logmes'); //寫入文件時,頭不能寫入"\r\n" 3.關閉文件: fclose($logfile); 4.判斷文件存在: file_exits() 5.肯定文件大小: filesize(); 6.刪除文件: unlink();
附:fopen列表
數據庫操做數據庫
數據庫操做類:
<?php class db_oper { private $hostname="127.0.0.1"; private $dbname="root"; private $dbpassword="52ebook"; private $dbdatabase="test"; private $conn; function construct() { $this->conn=new mysqli($this->hostname,$this->dbname,$this->dbpassword,$this->dbdatabase); if(mysqli_connect_errno()) { echo mysqli_connect_error(); die; } $this->conn->set_chartset("utf8"); } function exec($sql) { $this->conn->query($sql); return $this->conn->affected_rows; } function seldb($sql) { $result=$this->conn->query($sql); return $result->fetch_all(MYSQLI_ASSOC); } function getid($sql) { $this->conn->query($sql); return $this->conn->insert_id; } function destruct() { $this->close(); } } ?>
PHP服務器部署
1.不顯示程序錯誤信息: 修改php.ini文件,修改參數爲:display_errors=off,error_reporting=E_All & ~E_NOTICE 重啓apache服務器[Windows平臺測試經過] 注意點:1.確認修改的phi.ini文件爲apache服務器所使用的文件,可用phpinfo確認文件位置 2.設置文件上傳: file_uploads=on upload_max_filesize=8M post_max_size=8M upload_tmp_dir 文件上傳臨時目錄 注意點:post的值必定要大於upload的值 3.設置默認時區: date.timezone=Etc/GMT-8 4.日誌信息 error_log 日誌文件位置 log_errors 是否啓用日誌 log_errors_max_length 日誌信息的最大長度,0表示無限長度 附錄:常見的日誌級別
5.重啓apache命令: httpd -k restart [windows平臺,執行前先進入apache文件夾] service httpd restart [Linux平臺] 6.htaccess部署: 打開apache下的httpd.conf配置文件,進行參數修改 1. Options FollowSymLinks AllowOverride None 改成: Options FollowSymLinks AllowOverride All 2.開啓rewrite_module modules,即 去掉LoadModule rewrite_module modules/mod_rewrite.so註釋 3.重啓apache服務器 4.htaccess參數 RewriteEngine on <IfModule authz_core_module> Require all denied </IfModule> <IfModule !authz_core_module> Deny from all </IfModule> <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $1 !^(index\.php|images|js|img|css|robots\.txt) #在這裏寫要排除的資源等 RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 7.web服務器爲IIS時,需安裝ISAPI_Rewrite
Linux平臺下LAMP環境安裝實施
以CentOS6.5安裝LAMP: PHP:5.3.3 Mysql:5.1.71 Apache:Apache 2.2.15 以CentOS6.5 Yum安裝LAMP: PHP:5.3.3[CentOS6.5] Mysql:5.1.71[Yum] Apache:Apache 2.2.15[CentOS6.5] 查找某個文件:find / -name tnsnames.ora 機器名:hostname 環境檢查: libxml2-2.7.4.tar.gz[PHP] 解包: tar jxvf linux-2-4-2.tar.bz2 查看yum軟件版本: yum list php yum list mysql yum list httpd 查看rpm包版本: rpm -qa|grep httpd/mysql/php 查詢Linux版本:cat /etc/redhat-release Redhat/CentOS版本 1.關閉防火牆: /etc/init.d/iptables stop[臨時] chkconfig --level 35 iptables off[永久,重啓] 防火牆狀態:service iptables status selinux狀態:sestatus 關閉selinux: vi /etc/selinux/config SELINUX=disabled 重啓 2.安裝Apache 1.yum install httpd 2./etc/init.d/httpd restart 3.chkconfig httpd on 狀態查詢:service httpd status 查詢apache版本:httpd -v 配置文件:/etc/httpd/conf/httpd.conf 默認路徑:/var/www/html/,默認首頁:index.html 默認配置文件路徑:/etc/httpd/conf/httpd.conf 查詢apache安裝路徑:whereis httpd 3.安裝mysql 1.yum install mysql mysql-server 2./etc/init.d/mysql start 3.chkconfig mysqld on 4.mysql_secure_installation[設置mysql密碼] 5./etc/init.d/mysqld restart 狀態查詢:service mysqld status 查詢mysql版本:status select version(); 查詢安裝路徑:select @@basedir as basePath from dual; 卸載mysql: yum remove mysql mysql-server mysql-libs compat-mysql51 rm -rf /var/lib/mysql rm /etc/my.cnf 查看是否還有mysql軟件: rpm -qa|grep mysql 有的話繼續刪除 4.安裝PHP 1.yum install php 2./etc/init.d/httpd restart 3. yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt[PHP組件] 4./etc/init.d/httpd restart 5./etc/init.d/mysqld restart 附錄: 1.以yum方式安裝PHP5.5.24 1).yum remove php php-bcmath php-cli php-common php-devel php-fpm php-gd php-imap php-ldap php-mbstring php-mcrypt php-mysql php-odbc php-pdo php-pear php-pecl-igbinary php-xml php-xmlrpc 2).rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm 3).yum install php55w php55w-bcmath php55w-cli php55w-common php55w-devel php55w-fpm php55w-gd php55w-imap php55w-ldap php55w-mbstring php55w-mcrypt php55w-mysql php55w-odbc php55w-pdo php55w-pear php55w-pecl-igbinary php55w-xml php55w-xmlrpc php55w-opcache php55w-intl php55w-pecl-memcache 4).service httpd restart 查詢php版本: php -v 測試: 在/var/www/html中修改1.php信息 phpinfo(); 在phpinfo()中顯示php.ini文件路徑,在"etc/php.ini"下[CentOS] 設置: 1.Apache設置 vi /etc/httpd/conf/httpd.conf 1. ServerTokens OS 修改成: ServerTokens Prod (在出現錯誤頁的時候不顯示服務器操做系統的名稱) 2.ServerSignature On 修改成: ServerSignature Off (在錯誤頁中不顯示Apache的版本) 3.Options Indexes FollowSymLinks 修改成: Options Includes ExecCGI FollowSymLinks (容許服務器執行CGI及SSI,禁止列出目錄) 附錄: Apache虛擬目錄配置: 1.vi /etc/httpd/conf/httpd.conf Alias /herod "/var/www/herod" <Directory "/var/www/herod"> Options Indexes MultiViews Order allow,deny Allow from all </Directory> #cd /var/www #mkdir herod #echo "歡迎訪問herod的虛擬目錄">index.html 2.service restart httpd Apache虛擬主機配置: 1.vi /etc/httpd/conf/httpd.conf 添加: ServerName 58.130.17.168 NameVirtualHost 58.130.17.168 <VirtualHost 58.130.17.168> ServerName domain1.com DocumentRoot /var/www/domain1.com <Directory "/var/www/domain1.com"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost 58.130.17.168> ServerName domain2.com DocumentRoot /var/www/domain2.com <Directory "/var/www/domain2.com"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> 而後在/var/www/domain1.com和/var/www/domain2.com下建立不一樣的index.html文件: echo "domain1">/var/www/domain1.com/index.html echo "domain2">/var/www/domain2.com/index.html 2.vi /etc/hosts 添加: 58.130.17.168 test1.com 58.130.17.168 test2.com Nginx yum安裝: 1).rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm 2).yum install nginx 3).service nginx start Nginx默認配置文件路徑: vi /etc/nginx/conf.d/default.conf [ps -ef|grep nginx] Nginx,php配置: 1).安裝php-fpm yum install php-fpm 2).啓動php-fpm /etc/rc.d/init.d/php-fpm start 3).自動啓動 chkconfig php-fpm on 新建用戶,組: groupadd gx useradd -g gx gx 配置php-fpm: cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak vi /etc/php-fpm.d/www.conf user=gx group=gx 配置nginx支持php cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak vi /etc/nginx/nginx.conf user gx cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak vi /etc/nginx/conf.d/default.conf index index.php index.html index.htl location ~ \.php$ { #root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } 重啓服務 /etc/rc.d/init.d/php-fpm restart service nginx restart nginx版本:nginx -v 配置nginx之處CI rewrite: vi /etc/nginx/con.d/default.conf server { listen 80; server_name 192.168.1.125; //必定是IP或域名,不能用localhost[Linux下,localhost≠127.0.0.1] charset utf8; //設置編碼 root /usr/share/nginx/html; //網站根目錄 location / { index index.php index.html; } location ~ \.php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?$1 last; //關係url重寫 break; } access_log /logs/access.log; //設置日誌路徑 error_log /logs/error.log; } 注意點:調試CI時,如輸入CI日誌,在配置log_path時,需對相應路徑進行賦權 chown -R gx /logs chmod 777 /logs LNMP安裝:[http://lnmp.org/] 按官方步驟下載安裝[40min]。 查看mysql服務:service mysql status 鏈接Mysql:mysql -h127.0.0.1 -uroot -p [注意關閉防火牆] 默認安裝路徑爲:/usr/local/nginx|mysql|php Nginx配置虛擬主機: 修改nginx.conf配置文件,添加[未驗證]:
Nginx配置虛擬主機: location /test/ { root /home/wwwroot/default/; index index.php; }
Linux監控軟件,Cacti安裝 : 1.安裝rrdtool 1.rpm -ivh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 2.yum install rrdtool -y 2.安裝net-snmp 1.yum install net-snmp net-snmp-libs net-snmp-utils 2.配置net-snmp 在/etc/snmp/snmpd.conf中修改: view systemview included .1.3.6.1.2.1.1 爲: view systemview included .1.3.6.1.2.1 三、測試net-snmp # service snmpd start # snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.1.1.0 SNMPv2-MIB::sysDescr.0 = STRING: Linux cronos 2.4.28 #2 SMP ven jan 14 14:12:01 CET 2005 i686 3.安裝cacti 一、下載cacti cd /tmp wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz tar xzf cacti-0.8.8b.tar.gz mv cacti-0.8.8b /var/www/html/cacti cd /var/www/html/cacti 二、建立數據庫 mysqladmin --user=root -p create cacti 三、導入數據庫 mysql -uroot -p cacti < cacti.sql 四、建立數據庫用戶 shell> mysql -uroot -p mysql **mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';** mysql> flush privileges; 五、配置include/config.php $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactipassword"; /* load up old style plugins here */ $plugins = array(); //$plugins[] = 'thold'; /* Edit this to point to the default URL of your Cacti install ex: if your cacti install as at http://serverip/cacti/ this would be set to /cacti/ */ $url_path = "/cacti/"; /* Default session name - Session name must contain alpha characters */ #$cacti_session_name = "Cacti"; 六、設置目錄權限 useradd cactiuser chown -R cactiuser rra/ log/ 七、配置計劃任務 echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontab service crond restart service httpd restart 八、完成cacti的安裝 1) 在瀏覽器中輸入:http://www.yourdomain.com/cacti/ 默認用戶名:admin 密碼:admin 2) 更改密碼 3)設置cacti用到的命令路徑 配置: https://www.centos.bz/2012/06/cacti-monitor-traffic/ 1.登陸cacti,點擊「Devices」,而後點擊"Add"建立設備 2.而後輸入Description,Hostname,Host Template選擇「Generic SNMP-enabled Host」,SNMP Version通常選擇「Version 1」(固然得根據你具體的snmp如何配置)。完成後點擊"create"建立設備 3.接着在頂部點擊「Create Graphs for this Host」建立圖表 4.在「SNMP - Interface Statistics」下面會顯示你的網卡,選擇其中一個監控便可,咱們這裏選"eth0",以後單擊「create」。 5.如今已經成功建立圖表,咱們點擊左側的「Graph Management」查看圖表列表,此時已經能夠看到剛纔建立的圖表,點擊相應的圖表標題進去查看。 6.如今可能圖表還沒開始生成,最多等待5分鐘,5分鐘後圖表是建立了,但圖表沒有數據,須要等待一段時間程序收集數據
mysql小結
語句備查: 1.登陸 mysql -h127.0.0.7 -uroot -p 2.當前時間 select now(); 3.顯示版本 select version(); 4.顯示全部庫,表 show databases;show tables; 5.文件路徑 show variables like 'datadir%' 6.顯示錶結構 desc tablename; 7.查看當前庫 select database(); 8.聯查,判斷 select stu_table.sid as '學號',sname as '姓名',`subject` as '科目',score as '成績',case sex when 0 then '女' when 1 then '男' end as '性別' from score_table left join stu_table on score_table.sid=stu_table.sid 9.空判斷 select sname,class,IFNULL(score,60)score from stu_table left join score_table on score_table.sid=stu_table.sid 10.分頁,查詢 select * from food where title like '新%' order by title asc limit 0,3 11.時間格式化 select protitle,protent,date_format(protime,'%Y-%m-%d %H:%i')as protime,case prostatus when 0 then '未解決' when 1 then '已解決' end as prostatus from pro_tab; 12.判斷更新 update pro_tab set prostatus=if(1=prostatus,0,1) where proid='1'; 13.批量插入 insert into food(title,pic) values ('aa','aa'), ('bb','bb'), ('cc','cc') 14.修改表數據設置默認值 alter table food change pic pic varchar(1000) default '沒圖片'; 15.mysql開啓遠程鏈接 grant all PRIVILEGES on *.* to ted@'192.168.1.109' identified by '123456'; flush privileges; enterprise爲數據庫名,ted爲用戶帳號,123456爲用戶密碼。 15.Linux下,mysql數據庫顯示中文亂碼,修改編碼: show variables like 'character_%'; set character_set_server=utf8; 16.mysql庫目錄:/var/lib/mysql [CentOS6.5平臺,常規] 17.備份[Linux]: 1).cd /var/lib/mysql 2).mysqldump -u root -p databasename>databasename.sql 18.還原[Linux] 1).cd /var/lib/mysql 2).mysql -u root -p databasename<database.sql 注意點:在還原以前先確認是否存在數據庫,如不存在,則先建庫 19.mysql導入腳本: source /var/lib/enterprise.sql 20.mysql自動備份腳本[Linux]: 1. #! /bin/sh #File: /mysqlback.sh #database info: dataname="enterprise" datauser="root" datapass="52ebook" #Others vars bin_dir="/usr/bin" back_dir="/back" DATE=`date +%F` #Todo $bin_dir/mysqldump --opt -u$datauser -p$datapass $dataname|gzip>$back_dir/db_$DATE.gz 2.給腳本賦權 chomd 777 /mysqlback.sh 2.vi /etc/crontab 01 5 * * * root /home/mysql/backup.sh 或在crontab -e裏添加 備註:檢查cron服務狀態: 1.service crond status 2.crond日誌:/var/log/cron
21.兩表批量更新: update student inner join user_tab ON student.`准考證號`=user_tab.card_num set student.`身份證號`=user_tab.indentity_code; 22.查詢字段名 select column_name from information_schema.`COLUMNS` where TABLE_NAME='student'; 23.子查詢 select * from user_tab where card_num in (select `准考證號` from student where `姓名`='陳海') 24.聯合查詢 select * from user_tab,student where user_tab.card_num=student.`准考證號`; select * from student inner JOIN user_tab on student.`准考證號`=user_tab.card_num; 25.條件更新 update student set `備註`=case `准考證號` when '18625964' then '1' when '13425161' then '2' when '10725661' then '3' end ; 26.多條件排序 SELECT * from student where `身份證號` is null order by `備註` desc,`准考證號` asc; 27.Full join select * from student left JOIN user_tab on student.`准考證號`=user_tab.card_num UNION select * from student right JOIN user_tab on student.`准考證號`=user_tab.card_num ; 28.分數篩選,其中分數爲字符類型 SELECT * from student where `分數` BETWEEN 60 and 100 order by `分數`+0 asc 29.轉換,convert(field,datatype),cast(field,datatype) 30.移動表從一個庫到另外一個庫 rename table `work`.temp1 to b_work.temp1; 31.批量字段插入新表insert into `stu`(id,`name`,gender) select id,`name`,gender from exam_doctors; 支持類型: 二進制,同帶binary前綴的效果 : BINARY 字符型,可帶參數 : CHAR() 日期 : DATE 時間: TIME 日期時間型 : DATETIME 浮點數 : DECIMAL 整數 : SIGNED 無符號整數 : UNSIGNED 30.隨機排序 SELECT *,convert(`准考證號`,char) as `考號` from student where `分數` BETWEEN 60 and 100 order by rand() asc 31.聯合查詢 select concat(`姓名`,'-',`身份證號`) as `人員信息` from student; 32.追加時間 select date_add(now(),INTERVAL 100 day) 33.統計及格人數 select `class`,sum(case when score>=60 then 1 else 0 end),sum(case when score>=60 then 0 else 1 end) from student group by 1 34.跨庫查詢 select * from `work`.exam_doctors union select * from b_work.exam_doctors; 35.分組,排序 select t_jeff.* from (select vinnumber,max(channelid) as maxid from t_jeff GROUP BY vinnumber) m INNER JOIN t_jeff on t_jeff.vinnumber=m.VINNumber order by m.maxid desc,t_jeff.vinnumber,t_jeff.channelid desc; 36.獲取當前時間: select CURRENT_TIMESTAMP(); select CURRENT_DATE(); select CURRENT_TIME(); select now(); 37.格式化時間: select DATE_FORMAT(now(),'%y-%m-%d') as time 相關參數: %S, %s 兩位數字形式的秒( 00,01, . . ., 59) %i 兩位數字形式的分( 00,01, . . ., 59) %H 兩位數字形式的小時,24 小時(00,01, . . ., 23) %h, %I 兩位數字形式的小時,12 小時(01,02, . . ., 12) %k 數字形式的小時,24 小時(0,1, . . ., 23) %l 數字形式的小時,12 小時(1, 2, . . ., 12) %T 24 小時的時間形式(h h : m m : s s) %r 12 小時的時間形式(hh:mm:ss AM 或hh:mm:ss PM) %p AM 或P M %W 一週中每一天的名稱( S u n d a y, Monday, . . ., Saturday) %a 一週中每一天名稱的縮寫( Sun, Mon, . . ., Sat) %d 兩位數字表示月中的天數( 00, 01, . . ., 31) %e 數字形式表示月中的天數( 1, 2, . . ., 31) %D 英文後綴表示月中的天數( 1st, 2nd, 3rd, . . .) %w 以數字形式表示週中的天數( 0 = S u n d a y, 1=Monday, . . ., 6=Saturday) %j 以三位數字表示年中的天數( 001, 002, . . ., 366) % U 周(0, 1, 52),其中Sunday 爲週中的第一天 %u 周(0, 1, 52),其中Monday 爲週中的第一天 %M 月名(J a n u a r y, February, . . ., December) %b 縮寫的月名( J a n u a r y, February, . . ., December) %m 兩位數字表示的月份( 01, 02, . . ., 12) %c 數字表示的月份( 1, 2, . . ., 12) %Y 四位數字表示的年份 %y 兩位數字表示的年份 %% 直接值「%」 38.多表查詢 select * from (select exam_doctors.id,exam_doctors.`name`,exam_doctors.indentity_code,exam_fetch.card_num from exam_doctors LEFT JOIN exam_fetch on exam_doctors.id=exam_fetch.id) m RIGHT JOIN student on student.`准考證號`=m.card_num where `身份證號` is null 39.截斷表 truncate table tablename 40.查詢加強 select `所在地區`,avg(`分數`) as `平均分`,count(`身份證號`) as `人數` from ( select student.* from (select exam_doctors.id,exam_doctors.`name`,exam_doctors.indentity_code,exam_fetch.card_num from exam_doctors LEFT JOIN exam_fetch on exam_doctors.id=exam_fetch.id) m RIGHT JOIN student on student.`准考證號`=m.card_num) t GROUP BY `所在地區`; 41.字符長度 select * from student where LENGTH(trim(`姓名`))<>6 and LENGTH(trim(`姓名`))<>9; 42.group by,having select `所在地區`,avg(`分數`) as `平均分`,count(`身份證號`) as `人數` from ( select student.* from (select exam_doctors.id,exam_doctors.`name`,exam_doctors.indentity_code,exam_fetch.card_num from exam_doctors LEFT JOIN exam_fetch on exam_doctors.id=exam_fetch.id) m RIGHT JOIN student on student.`准考證號`=m.card_num) t GROUP BY `所在地區` HAVING `人數`>300; 43.判斷與統計 select 所在地區,case when `分數`>=60 then '及格' when `分數`<60 then '不及格' end as `成績`,count(`身份證號`) as 人數 from student group by `所在地區`,`成績`; 44.子查詢 select card_num from exam_fetch where card_num not in (select `准考證號` from student); 45.整表插入 insert into student2 SELECT * from student; 46.Linux下,mysql 查詢亂碼: 查詢前,先執行:set NAMES 'utf8'
CI框架學習總結
首頁配置: 1.$config['base_url']='http://127.0.0.1/CodeIgniter'; [config.php] 2.$config['index_page']='index.php'; [config.php] 3.$route['default_controller']='Contacts'; [routes.php] 數據庫配置:database.php 鏈接數據庫: 1.$autoload['libraries']=array('database'); [autoload.php] 2.$this->load->database(); 全局變量: define('SysName','SysName'); [index.php] 錯誤級別定義: 1.error_reporting()設置 [index.php] 2.log_path設置日誌文件路徑,按日期記錄,log-time,一天一個文件 錯誤日誌記錄: $config['log_threshold']=0控制 [config.php] 定義錯誤信息: 修改404錯誤信息: 修改function show_404中的顯示信息 [system/core/Exceptions.php] 錯誤頁面:位於views/errors文件夾下 3.CI大小寫的問題[linux下必須嚴格遵照此規則]: Control文件爲首字母大寫,Control中調用的module方法爲小寫 Views文件爲小寫 Module文件爲首字母爲大寫
Linux經常使用命令
1.重啓網卡:service network restart 2.執行sh腳本:sh mysqlback.sh 3.查看日誌:tail -f sys.log 4.更正系統時間:ntpdate time.nist.gov 5.開機自動矯正時間:chkconfig ntpd on 6.重啓:reboot 7.版本信息:cat /etc/issue [centos]
微信企業平臺開發
: 基礎概念:
功能:
1).公告通知
2).知識管理
3).企業文化建設
4).手機企業通信錄
主動調用:
1).https協議
2).json數據格式
3).UTF編碼
4).訪問域
5)數據不加密
回調模式:
1URL
2.Token
3.EncodingAESKey
經驗與技巧
1.Linux下,默認不開啓php.ini的error_log,如需調試需開啓 [CentOS6.5] 2.PHP版本不一樣,對mysqli的支持不一樣,某些方法不能用 [CentOS6.5] 3.在Linux下,htaccess文件爲隱藏文件 4.Linux腳本調試 輸出相關路徑:echo $bin_dir> /back/1.log 5.虛擬機下(宿主機ip自動獲取),centos可上內網不能上外網,則: cd /etc/sysconfig/network-scripts/ vi route-ech0[新建] via 192.168.1.1 保存,service restart network,然後選取DHCP自動鏈接便可上外網 6.Linux防火牆開放端口: 1.vi /etc/sysconfig/iptables 2.添加條目: -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 端口:80爲web端口,3306爲mysql端口 7.CentOS設置靜態IP: 1.vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 //指出設備名稱 BOOTPROT=static //啓動類型 dhcp|static BROADCAST=192.168.1.203 //廣播地址 HWADDR=00:06:5B:FE:DF:7C //硬件Mac地址 IPADDR=192.168.0.2 //IP地址 NETMASK=255.255.255.0 //子網掩碼 NETWORK=192.168.0.0 //網絡地址 GATEWAY=192.168.0.1 //網關地址 ONBOOT=yes //是否啓動應用 TYPE=Ethernet //網絡類型 2.service network restart
問題備查
: 1.Linux下,Another MySQL daemon already running with the same unix socket
service mysqld stop mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak service mysqld start
2.Linux下,查看端口占用
netstat -tunlp |grep 22 lsof -i:端口號
3.Linux下,查看ssh服務
service sshd status 配置文件:vi /etc/ssh/sshd_config
4.Another app is currently holding the yum lock,
rm -rf /var/run/yum.pid
5.httpd已死,可是subsys被鎖
1.cd /var/lock/subsys 2.rm httpd 3.service httpd restart