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列表



数据库操作

数据库操作类:
<?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
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 i686 3.安装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 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";
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 -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

PHP,mysql,Linux,CI框架学习总结的更多相关文章

  1. 各种demo——CI框架学习

    各种demo——CI框架学习   寒假学习一下CI框架,请各位多多指教! 一.CI的HelloWorld! 注意:CI禁止直接通过文件目录来访问控制器. ./application/controlle ...

  2. ci框架学习告一段落,总结一下

    从网上弄了一张框架学习思维导图,从图中就可以看出ci用了设计模式中的MVC架构,使得用起来很简单方便 用了大概两个星期开发了一个<文章管理系统>觉得开发过程中学到了很多,挺不错的,而且在学 ...

  3. PHP CI框架学习

    CI框架的URL辅助函数使用 URL 辅助函数文件包含一些在处理 URL 中很有用的函数 加载辅助函数 在使用CI框架的使用经常碰到跳转和路径方面的问题,site_url()和base_url()很容 ...

  4. 【ci框架学习】环境搭建

    系统 -- Ubuntu 14.0(虚拟机linux 实体机Windows) 目标环境 -- lnmp 附加内容: 1.目录共享(方便代码编写) 2.使用secure crt终端软件连接(便于操作,不 ...

  5. CI框架学习笔记

    打印SQL语句$this->dbRead->last_query(); 重映射方法正如上文所说,URI 的第二段通常决定控制器的哪个方法被调用.CodeIgniter 允许你使用 _rem ...

  6. CI框架学习——基本的用法(一)

    一.必备知识 1.如何访问你的页面 我在控制器下面建立了admin文件夹,此文件夹下有login.php 文件,我们现在要访问这个文件 http://localhost/gradesystem/ind ...

  7. 【ci框架学习】控制器-视图

    基础的东西就不写了,网上大把的教程,可以慢慢磨.这里说些要注意的要点. 1.所有控制器都必须间接或者直接继承控制器基类 CI_Controller. 2.文件命名尽量小写,因为ci使用的是pathin ...

  8. PHP CI框架学习笔记-分页实现程序

    视图html  <div id="body"> <form action="/index.php/search/index/" method= ...

  9. ci框架学习中注意的事项

    视图: 加载视图:$this->load->view('name'); 一次可以加载多个视图,如: public function index() { $data['page_title' ...

随机推荐

  1. 修改hadoop的jar包运行时候分配的jvm内存

    在hadoop-env.sh中修改参数添加 export HADOOP_HEAPSIZE="4096" 设置分配的最大jvm内存为4096,一般用于jar包里面除了执行map和re ...

  2. 并查集&线段树&树状数组&排序二叉树

    超级无敌巨牛逼并查集(带权并查集)https://vjudge.net/problem/UVALive-4487 带删点的加权并查集 https://vjudge.net/problem/UVA-11 ...

  3. Codeforces 786A Berzerk(博弈论)

    [题目链接] http://codeforces.com/problemset/problem/786/A [题目大意] 有两个人,每个人有一个数集,里面有一些数,现在有一个环,有个棋子放在1, 有个 ...

  4. 【费马小定理+快速幂+逆元】BZOJ3240-[NOI2013]矩阵游戏

    [题目大意] 若用F[i][j]来表示矩阵中第i行第j列的元素,则F[i][j]满足下面的递推式:F[1][1]=1F[i,j]=a*F[i][j-1]+b (j!=1)①F[i,1]=c*F[i-1 ...

  5. 显示字符 Exercise06_12

    /** * @author 冰樱梦 * 时间:2018年下半年 * 题目:显示字符 *1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J ...

  6. Problem R: 零起点学算法13——求2个时间之间的分钟数

    #include<stdio.h> int main() { int a1,b1,a2,b2,s; scanf("%d:%d",&a1,&b1); sc ...

  7. 【R笔记】给R加个编译器——notepad++

    R的日记-给R加个编译器 转载▼ R是一款强大免费且开源的统计分析软件,这是R的长处,可也是其“缺陷”的根源:不似商业软件那样user-friendly.记得初学R时,给我留下最深印象的不是其功能的强 ...

  8. Java高级架构师(一)第07节:远程使用以及冲突解决

  9. iOS开发——随机数的使用

    1).arc4random() 比较精确不需要生成随即种子        使用方法 :                  通过arc4random() 获取0到x-1之间的整数的代码如下:       ...

  10. 水晶报表导出完美EXCEL表格

    水晶报表自带的导出Excel不太完美(这一点与SQL的SSRS相比就差太远了),导出的文件没有网格线,而且非常容易出现跨行跨列的现象,要做一个符合要求的报表还真要花不少的时间与精力去调试. 下面我简单 ...