兼容 php 7.2
php 7.2 废弃了 create_function 函数,为了更好的兼容我们去除了 tool 方法;
请大家在自定义工具类时遵循命名空间,第三方工具类使用时手动 include 并遵循 \ 顶级命名空间调用,如 :
$tool = new \xxxTool();
兼容 mysql 8
php 与 mysql 8 连接会报错 :
报错:PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
原因 :
由于Mysql8.0将默认的字符集改为了utfmb4,因此和客户端(不仅仅是PHP)的通信无法识别,我们需要更改my.cnf来指定字符集。
解决方案 :
修改 mysql 8 配置 : my.ini 调整编码
[mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=D:\mysql8 # 设置mysql数据库的数据的存放目录 datadir=D:\mysql8\Data #忘记密码时使用 #skip-grant-tables #设置协议认证方式(重点啊) default_authentication_plugin=mysql_native_password [client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] collation-server = utf8_unicode_ci character-set-server = utf8
*** graceCms 付费用户调整 ***
1. 打开 admin/controllers/ccode.php, 替换 函数内容
public function fields(){ if(empty($this->gets[0])){$this->json('参数错误', 'error');} $db = db($this->gets[0]); $pdo = $db->pdo; $sta = $pdo->prepare( 'select ORDINAL_POSITION,COLUMN_NAME ,DATA_TYPE, COLUMN_COMMENT from information_schema.columns where table_schema = ? and table_name = ? order by ORDINAL_POSITION asc'); $sta->execute(array(sc('db','dbname'), sc('db','pre').$this->gets[0])); $fields = $sta->fetchAll(\PDO::FETCH_ASSOC); if(empty($fields)){ $this->json('数据表名称错误', 'error'); } $str = ''; $checkType = '<select> <option value="int">int</option> <option value="string">string</option> <option value="between">between</option> <option value="betweenD">betweenD</option> <option value="betweenF">betweenF</option> <option value="same">same</option> <option value="sameWith">sameWith</option> <option value="notSame">notSame</option> <option value="email">email</option> <option value="phone">phone</option> <option value="zipCode">zipCode</option> <option value="reg">reg</option> <option value="fun">fun</option> </select>'; foreach($fields as $field){ $str .= '<tr> <td>'.$field['COLUMN_NAME'].'</td> <td><input type="text" value="'.$field['COLUMN_COMMENT'].'" class="layui-input" /></td> <td>'.$checkType.'</td> <td><input type="text" class="layui-input" /></td> <td><input type="text" class="layui-input" value="'.$field['COLUMN_COMMENT'].'应为 字" /></td> <td><input value="1" title="展示" type="checkbox" checked="checked" lay-skin="primary" /></td> <td><input value="1" title="必填" type="checkbox" checked="checked" lay-skin="primary" /></td> </tr>'; } $this->json($str, 'ok'); }
2. 打开 phpGrace.php 删除 tool 函数的定义;