PHP,mysql,CI框架学习总结


PHP标记

1.Xml风格<?php ?>
2.简短风格  <?  ?>  需在php.ini中开启short_open_tag
3.asp风格   <%  %>  需在php.ini中开启asp.tags
4.脚本风格  <script language="php"></script>

PHP注释

1.单行注释://,#
2.多行注释:/* */

变量申明

1.以$为开头
2.大小写敏感

静态变量Eample:

class test{public static $constr="这是一个静态变量";}echo test::$constr;

全局变量

1.$_GET
2.$_POST
3.$_REQUEST
4.$_FILES
5.$_SESSION             使用前,需session_start();
6.$_COOKIE
7.$_SERVER
8.$_ENV
9.$_GOLBALS

基本函数

    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");         //记录系统日志

基本字符串函数

    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数据进行解码

数组函数

    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()              //使用回调函数,操作数组,改变数组值

**文件操作

1.打开文件:    $logfile=fopen("1.txt",'a');
2.写入文件:    fwrite($logfile,'logmes');      //写入文件时,头不能写入"\r\n"
3.关闭文件:    fclose($logfile);
4.判断文件存在:    file_exits()
5.确定文件大小:    filesize();
6.删除文件:         unlink();

附:fopen列表

数据库操作

数据库操作类:
<?phpclass 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=onupload_max_filesize=8Mpost_max_size=8Mupload_tmp_dir      文件上传临时目录注意点:post的值一定要大于upload的值3.设置默认时区:date.timezone=Etc/GMT-84.日志信息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 httpd3.安装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版本:statusselect 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.241).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-xmlrpc2).rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm3).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-memcache4).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.confAlias /herod "/var/www/herod"<Directory "/var/www/herod">Options Indexes MultiViewsOrder allow,denyAllow from all</Directory>#cd /var/www#mkdir herod#echo "欢迎访问herod的虚拟目录">index.html
2.service restart httpdApache虚拟主机配置: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.comNginx yum安装:1).rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm2).yum install nginx3).service nginx start
Nginx默认配置文件路径:
vi /etc/nginx/conf.d/default.conf   [ps -ef|grep nginx]Nginx,php配置:1).安装php-fpm yum install php-fpm2).启动php-fpm /etc/rc.d/init.d/php-fpm start3).自动启动 chkconfig php-fpm on
新建用户,组:groupadd gxuseradd -g gx gx
配置php-fpm:cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbakvi /etc/php-fpm.d/www.confuser=gxgroup=gx
配置nginx支持phpcp /etc/nginx/nginx.conf /etc/nginx/nginx.confbakvi /etc/nginx/nginx.confuser gx cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbakvi /etc/nginx/conf.d/default.confindex index.php index.html index.htllocation ~ \.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 restartservice 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 /logschmod 777 /logsLNMP安装:[http://lnmp.org/]
按官方步骤下载安装[40min]。
查看mysql服务:service mysql status
连接Mysql:mysql -h127.0.0.1 -uroot -p  [注意关闭防火墙]
默认安装路径为:/usr/local/nginx|mysql|phpNginx配置虚拟主机:
修改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 -y2.安装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
3、测试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 i6863.安装cacti
1、下载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
2、创建数据库
mysqladmin --user=root -p create cacti
3、导入数据库
mysql -uroot -p cacti < cacti.sql
4、创建数据库用户
shell> mysql -uroot -p mysql
**mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';**
mysql> flush privileges;
5、配置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 installex: if your cacti install as at http://serverip/cacti/ thiswould be set to /cacti/
*/
$url_path = "/cacti/";/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";
6、设置目录权限
useradd cactiuser
chown -R cactiuser rra/ log/
7、配置计划任务
echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontab
service crond restart
service httpd restart
8、完成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 -p2.当前时间  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.sid9.空判断select sname,class,IFNULL(score,60)score from stu_table left join score_table on score_table.sid=stu_table.sid10.分页,查询select * from food where title like '新%' order by title asc limit 0,311.时间格式化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/mysql2).mysqldump -u root -p databasename>databasename.sql18.还原[Linux]1).cd /var/lib/mysql2).mysql -u root -p databasename<database.sql注意点:在还原之前先确认是否存在数据库,如不存在,则先建库19.mysql导入脚本:source /var/lib/enterprise.sql20.mysql自动备份脚本[Linux]:1.#! /bin/sh#File: /mysqlback.sh#database info:dataname="enterprise"datauser="root"datapass="52ebook"#Others varsbin_dir="/usr/bin"back_dir="/back"DATE=`date +%F`#Todo$bin_dir/mysqldump --opt -u$datauser -p$datapass $dataname|gzip>$back_dir/db_$DATE.gz2.给脚本赋权chomd 777 /mysqlback.sh2.vi /etc/crontab01 5 * * * root /home/mysql/backup.sh或在crontab -e里添加备注:检查cron服务状态:1.service crond status2.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-eth0DEVICE=eth0                 //指出设备名称BOOTPROT=static             //启动类型 dhcp|staticBROADCAST=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 stopmv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bakservice mysqld start

2.Linux下,查看端口占用

     netstat -tunlp |grep 22lsof -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/subsys2.rm httpd3.service httpd restart

转载于:https://www.cnblogs.com/fangbaiyi/p/4569674.html

PHP,mysql,Linux,CI框架学习总结相关推荐

  1. php 里的cl框架手册,CI框架学习笔记(一)

    本文是CI框架学习笔记的第一篇,主要介绍了CI框架的环境安装,基本术语以及框架流程,非常的详细,有需要的朋友可以参考下 最开始使用CI框架的时候,就打算写一个CI源码阅读的笔记系列,可惜虎头蛇尾,一直 ...

  2. PHP的CI框架学习

    一.前言 完全没想到新公司会使用CI框架,虽然一直听说,但是大家平时还是用laravel,yii,tp多一些,第一次接触CI,值得记录一下. 网上关于CI的文档很多,也很全面,博主这里只是简单的记录下 ...

  3. linux php执行ci框架,PHP CI框架学习之路径访问

    CI是一个PHP写的框架,使用它写网站非常方便,但是也会也有一些纠结的问题,比如说其中文件的路径访问. CI严格贯彻MVC思想,因此基于此思想的文件访问也比较严格,controllers控制器是所有v ...

  4. linux firmware 框架,学习整理:arm-trusted-firmware

    本文以AArch64为准,内容以翻译原文为主. 资源说明 基本介绍 权限模型 (Exception Levels) 基本分为EL3-EL0,从高level转低level通过ERET指令,从低level ...

  5. django2 mysql驱动_Django框架学习(二)Django连接Mysql数据库,实现表的增删改查

    创建一个Django项目 方法: 1.使用 django-admin.py 管理工具来创建项目 2.用Pycharm专业版可以直接创建Django 项目 我直接用Pycharm创建的项目,比较简单,也 ...

  6. CI框架学习笔记第三天

    此文章为自己书写,在Word上做的笔记,然后拷贝到这上边的,无任何抄袭.另外若是程序有任何问题可以评论,也可私信我. 若是想看整个学习笔记代码和数据库可点击此处(包含个人书写的项目代码及数据库文件). ...

  7. 后盾网-CI框架实例教程-马振宇 - 学习笔记(6)

    第六节视频:6.CI框架学习-实例操作添加栏目如何定义使用模型以及配置数据库与利用AR增 本节要点: 1.定义模型Model 2.输入类使用 3.数据库配置 4.使用AR类操作数据库 5.激活调试模式 ...

  8. CI框架源码学习笔记7——Utf8.php

    愉快的清明节假期结束了,继续回到CI框架学习.这一节我们来看看Utf8.php文件,它主要是用来做utf8编码,废话不多说,上代码. class CI_Utf8 {/*** Class constru ...

  9. 后盾网-CI框架实例教程-马振宇 - 学习笔记(7)

    第七节视频:    CI框架学习-实例操作利用AR类对栏目进行查.删.改动作 取cid的方法: $cid = $this->uri->segment(4);//取第4个片段: /*查询对应 ...

最新文章

  1. visual studio 代码提示插件_程序员请收好:10个非常实用的 VS Code 插件
  2. 用友BQ商业智能设计模式——概述
  3. php和java语言_JAVA语言和PHP语言的比较
  4. vscode设置键盘快捷键
  5. ajax是操作系统吗,ajax 跟post 可以设置它是否同步执行
  6. Prefactoring——Introduction
  7. 二叉树 的建立及遍历 过程
  8. 学习python的第五天
  9. grails 保存图片
  10. xp本地调试php代码,Windows XP下简单配置本机PHP调试环境
  11. java笔试题(题目+解析)
  12. IDL处理葵花8Himawari-8标准HSD数据——制作大气校正数据集(卫星角度数据)
  13. VMware中Linux网络配置
  14. C# 本地图片转Base64码和Base64码显示
  15. MTK 平台TP 驱动
  16. 股票 市盈率(PE)
  17. 【钉钉-场景化能力包】企业系统和钉钉工作流打通
  18. XMind揭秘:汽车的世界
  19. anaconda自动安装jupyter后打开E盘
  20. 博学谷 - CSS笔记23 - 常见布局技巧

热门文章

  1. 新西兰储备银行数据遭泄露
  2. SaltStack Salt 开源管理框架修复2个严重漏洞,多款开源产品等受影响
  3. 谷歌更新漏洞披露规则:不管补丁打没打,够90天才披露
  4. MySQL事务隔离级别解密
  5. 《战争论》第四篇《战斗》的主要内容
  6. chattr lsattr
  7. Haproxy相关概念解析
  8. Real Application Testing Database Replay、SPA的价格和介绍
  9. C# WinForm开发系列 - Regular Expression
  10. java中case语句_Java:switch-case语句