这是我参与11月更文挑战的第12天,活动详情查看:2021最后一次更文挑战
按照laravel文档使用Composer安装laravel时遇到问题:
[InvalidArgumentException]
Could not find package laravel/installer. It was however found via repository search, which indicates a consistency issue with the repository.
其实就是composer 的中国镜像出了问题,
换成另外一个地址:
composer config -g repo.packagist composer packagist.org
之后重新执行安装命令:
composer global require laravel/installer
问题解决,安装成功:
在laravel框架中写原生sql语句,insert 表名后面一定要加要插入数据的具体字段,否则报错
public function add(){
// $db =DB::table('stadium');
// $result= DB::insert
//('insert into users (id, name) values (?, ?)', [2, '兰新宇']);
$result= DB::insert
("insert into stadium(visit_date,people) values(?,?)",['2019-05-05','300']);
return $result;
}
laravel框架自定义路由404问题,解决:配置服务器代理
f (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1;
}
注意控制器函数命名问题,不要与关键字等一些敏感词汇重复,例如做表单验证时函数名不能为validate,否则报错
laravel 框架双引号解析变量,单引号不解析变量
php中 base64_decode与base64_encode加密解密函数
加密
$string='http://examply.net';
return base64_encode($string); //aHR0cDovL2V4YW1wbHkubmV0
解密
$string='aHR0cDovL2V4YW1wbHkubmV0';
return base64_decode($string); //http://examply.net
PHP后台返回二维码数据如何在前端显示
设置返回的数据类型为blob
利用返回的数据生成Blob对象,注意用数组包裹
然后调用window.URL.createObjectURL(blob)生成url地址
前端利用img标签,src属性为刚才生成的url地址
self.axios.get("/index.php/backcalendar/createSignInorOutCode?open_id="+open_id,
{
responseType: 'blob'
})
.then(result=>{
console.log(result);
const blob = new Blob([result.data])
const url = window.URL.createObjectURL(blob)
self.SignInorOutCodeImgSrc=url
self.signInorOutCodeTitle="扫码签到";
self.SignInorOutVisible=true;
})
mysql数据库如果表中某字段名desc,sql语句中使用desc是要加反引号,例如update语句
UPDATE table1 SET `desc` = 'example' WHERE id = 100;