PHP artisan migrate 报错显示 could not find driver ,怎么办?

记录下自己的错误

一、

1、原因是没有pdo扩展导致的,

2、解决办法:打开php.ini,然后去掉以下两行代码之前的分号(;)即可。如下;

extension=php_pdo_firebird.dll

extension=php_pdo_mysql.dll

二、

但是我运行pdo链接,还是报这个错。最后发现是自己的pdo链接字符串有问题,导致无法连接。原因是单引号与双引号的作用没有搞明白,单引号下的变量是php是不会去解析的,双引号与没有符号下的变量php才会去解析。


原文:https://blog.csdn.net/sinat_34322082/article/details/80417002

以上方法都不对的情况下:

本地环境:

 

 

发现在本地使用PHPstorm中执行php artsian insert:order 命令执行失败,无法找到驱动,最后发现在vagrant搭建的环境中,本地配置不全,在使用Xshell连接到这机器即可

vagrant环境

 

 

 

 

 

php artisan make:command Building/InsertOrder  

生成的脚本文件存储在command/building 目录下,带命名空间

 

脚本文件:InsertOrder.PHP

<?php

namespace App\Console\Commands\Building;

use App\Building;
use App\ModelList\Buildings\BuildingPaymentTest;
use Illuminate\Console\Command;

class InsertOrder extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'Insert:order';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '修改补充buildingpayment表中的订单编号';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //补充订单编号

        $this->index();
    }

    /**
     * @author lxw
     */
    public function index()
    {

        $buildingsTest = BuildingPaymentTest::get(['id', 'building_id', 'created_at']);

        if ($buildingsTest->isEmpty()) {
            dd('没有数据');
        }

        $num = 0;

        foreach ($buildingsTest as $building) {
            $createTime = date('Ymd', strtotime($building['created_at']));
            //生成唯一订单编号,规则:年月日+5位随机数
            $randStr = $createTime . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
            $companyId = Building::where('id', $building->building_id)->withTrashed()->get(['company_id'])->toArray();

            if (empty($companyId)) {
                continue;
            }
            $updateParam = [
                'order_id' => $randStr,
                'company_id' => $companyId[0]['company_id'],
                'owner_id' => 1,
                'sales_person' => 'admin',
                'payment_amount' => '0',
                'start_time' => $building['created_at'],
            ];
            BuildingPaymentTest::where('building_id', $building->building_id)->update($updateParam);


            $num++;
            dump('楼宇' . $building->building_id . '完成,已经完成' . $num . '条');
//            dd('停止一下');
        }

        dd('全部完成');
    }


}

  




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lxw1844912514

你的打赏就是对我最大的鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值