博客

代码片--持续更新

2016-08-22 15:20:13浏览(4191)作者:itnoob 来源:本站原创

//间接判断是否为空
$a = null;//$a = '';
$b = explode(',',$a);

var_dump($b[0]);
//合并数组并去除重复项
<?php
$a = ['css','bug','hack'];
$b = ['ghost','大写','小心','hack','css'];

$c = array_unique(array_merge($a,$b));

?>
<!--placeholder 换行-->
placeholder="非主流软件 &#13;&#10; 非主流软件科技"
//修改mysql root 密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
//mysql8.0
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your-password';

//mysql 允许远程登录

需要手动增加可以远程访问数据库的用户。
方法一、本地登入mysql,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,将"localhost"改为"%"
#mysql -u root -proot
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
方法二、直接授权(推荐)
从任何主机上使用root用户,密码:youpassword(你的root密码)连接到mysql服务器:
# mysql -u root -proot 
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
操作完后切记执行以下命令刷新权限 
FLUSH PRIVILEGES
TP5模型查询 Charge为模型类

//获取满足条件的数据
Charge::where($condition)->column('*'); //'*'代表所有列  数组
Charge::where($condition)->select(); // 对象数组

//获取满足条件的一条数据
Charge::where($condition)->find(); // 单个对象
Charge::where($condition)->find()->toArray(); // 单个数组 时间戳转换
Charge::where($condition)->find()->getData(); // 单个数组 原始数据

//动态查询 根据某字段查询某条记录
Charge::getById(1);
Charge::getById(1)->toArray();
Charge::getById(1)->getData();

//获取某一字段的值
Charge::where($condition)->value('status');
Charge::getFieldById($id,'status');


标签:代码片,数组,placeholder,mysql