备份数据的PHP代码

2017-01-16 21:29:08

<?php /******   备份数据库结构 ******/              /*       函数名称:table2sql()       函数功能:把表的结构转换成为SQL       函数参数:$table: 要进行提取的表名       返 回 值:返回提取后的结果,SQL集合       函数作者:heiyeluren       */ &n...

评论(0) 浏览(1297)

mysql的一些常用命令

2017-01-16 21:28:27

显示数据库列表: show databases; 创建库: create database 库名; 给表改名:rename table ztemp to ztemp4; 删除表 : drop table 表名; 修改字段属性: alter table bbabase change news_id id varchar(5) not null; 在表中增加一字段: alter table bbabase add leave_time datetime not null ; ...

评论(0) 浏览(1418)

sql小技巧

2017-01-16 21:27:57

1.查询数据库里有多少张表(把下面的表名换掉就行了) SELECT count(*) TABLES, table_schema FROM information_schema.TABLES   where table_schema = 'jg_game' GROUP BY table_schema;    2.修改数据库密码(在MYSQL-FRONT里执行就行了) SET PASSWORD FOR 'root'@'localhost' = PASSWORD( '********' ) 3.复制表数据到另外一个表insert into table select * from tableb;  1.INSERT INTO SELECT语句  &nb...

评论(0) 浏览(1337)

条件查询插入数据

2017-01-16 21:27:17

如果是正值插入0 否则是1 IF后面跟着的是条件 UPDATE some_table SET an_int_value = IF(an_int_value=1, 0, 1) update sg_player_1 set player_lotto_times=if(player_lotto_times-1>=0,player_lotto_times-1,0) WHERE player_uid=1; 这样就能保证插入的值不会为负数 改变查询的结果 表示从第3个字符起替换4个字符 用单词 WHAT   SELECT INSERT('Quadratic', 3, 4, 'What'); 结果:'QuWhattic' E。G。 SELECT INSERT(name, 2, 4, 'What'...

评论(0) 浏览(1359)

按时间段查询

2017-01-16 21:25:52

当天记录 select * from table where DATE_FORMAT(b.buy_datetime,'%Y-%m-%d')=current_date() 前一天记录 select * from table where DATE_FORMAT(b.buy_datetime,'%Y-%m-%d')=date_sub(current_date(),interval 1 day) 当月记录 select * from table where DATE_FORMAT(b.buy_datetime,'%Y-%m')=DATE_FORMAT(current_date(),'%Y-%m') //---------------------------------- 一周的  se...

评论(0) 浏览(1383)

删除数组中某个元素

2017-01-13 15:54:31

删除数组中某个元素 方法一:用array_filter方法配合 function del($var) {  $arr = array('test',1,'adf',2);  if(!in_array($var,$arr))return true; } print_r(array_filter($array1, "del")); 方法二:用unset unset(array['key']); ...

评论(0) 浏览(1203)

判断某个数所在的位置

2017-01-13 15:53:54

判断某个数所在的位置 方法一: 这上方法感觉是更优化,但是用测试时间来算反而更长。数据量大的时候没测过。 $stage_data = array(0,26,51,76,100); array_push($stage_data,$stage_num); $data = array_unique($stage_data); asort($data); return array_search($stage_num,$data); 方法二: if($stage_num>0 && $stage<26){  $stage = '1'; } if($stage_num>=26 && $stage<51){  $stage = '2'; } if($stage_nu...

评论(0) 浏览(1495)

小数点的取舍

2017-01-13 15:53:13

小数点的取舍 ceil 向上取整 ,round四舍五入  ,floor 向下取整 echo round(3.4);         // 3 echo round(3.5);         // 4 echo ceil(4.3);    // 5 echo ceil(9.999);  // 10 echo floor(4.3);   // 4 echo floor(9.999); // 9 ...

评论(0) 浏览(1269)

ssh2提示服务器密码错误,请再试一次

2017-01-13 15:27:28

SSH服务器拒绝了密码,xshell连不上虚拟机怎么办 SSH服务器拒绝了密码,xshell连不上虚拟机怎么办   2015-02-03 源自: Linux达人养成计划 I... 2-8 29337 浏览 6 回答 Hell_Demon_ 应该是sshd的设置不允许root用户用密码远程登录 修改 vim /etc/ssh/sshd_config 找到# Authentication: LoginGraceTime 120 PermitRootLogin without passwd StrictModes yes 改成 # Authentication: LoginGraceTime 120 PermitRootLogin yes StrictModes yes 重启虚拟机 &...

评论(0) 浏览(1404)

Laravel 精选资源大全

2017-01-12 17:45:27

Laravel 精选资源大全(持续更新) http://laravelacademy.org/post/153.html Laravel 5.3 中文文档 https://laravel-china.org/docs/5.3 http://packalyst.com/ laravl的一些Packages https://laravel-china.org/ Laravel 社区 http://www.golaravel.com/post/laravel-5-0-directory-structure-and-namespace/ Laravel 5.0 系列 - 之目录结构与命名空间 PHP 设计模式系列 —— 资源库模式(Repository) http://laravelacademy.org/post/3053.htm...

评论(0) 浏览(1367)

Powered by PHP 学习者(mail:517730729@qq.com)

原百度博客:http://hi.baidu.com/ssfnadn

备案号:闽ICP备17000564号-1

开源中国 PHPCHINA