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

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

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

本地环境:

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

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

 

 

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

vagrant环境

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

 

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

 

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

 

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

 

php artisan make:command Building/InsertOrder  

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

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

 

脚本文件: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('全部完成');
    }


}

  

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/112357.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 什么是404页面,如何正确设置制作404页面

    什么是404页面,如何正确设置制作404页面
    什么是404页面?
      404网页是用户尝试访问网站不存在的网页(由于用户点击了损坏的链接、网页已被删除或用户输入了错误的网址)时看到的页面。之所以称为404网页,是因为针对丢失网页的请求,网络服务器会返回404HTTP状态代码,表明该网页未找到。
    404页面的目的是:告诉浏览者其所请求的页面不存在或链接错误,同时引导用户使用网站其他页面而不是关闭窗口离开。
    404对搜索引擎优化seo的影响
      搜索引擎通过HTTP状态码来识别网页的状态。当

    2022年7月27日
    11
  • 八路抢答器单片机c语言程序_八路抢答器单片机c语言程序

    八路抢答器单片机c语言程序_八路抢答器单片机c语言程序该楼层疑似违规已被系统折叠隐藏此楼查看此楼改成开始前抢答蜂鸣器响,红灯亮#include#defineuintunsignedint#defineucharunsignedcharsbitSW1=P1^0;//******sbitSW2=P1^1;//*八*sbitSW3=P1^2;//*路*sbitSW4=P1^3;//*抢*sb…

    2022年10月20日
    1
  • int什么数据类型_int16是什么数据类型

    int什么数据类型_int16是什么数据类型int16,int32,int64等类型的区别Int16意思是16位整数(16bitinteger),相当于short占2个字节。Int32意思是32位整数(32bitinteger),相当于int占4个字节。Int64意思是64位整数(64bitinterger),相当于longlong占8个字节。…

    2022年8月15日
    5
  • SIGINT信号

    SIGINT信号原文链接 http hi baidu com l1l1888 blog item 9024a2fe75c6 html 用户按下 ctrl c 时 进程被中断 catch 被执行 中断处理函数处理完毕 root localhost001 catsigint demo cpp include include includeusing st

    2025年7月15日
    0
  • 解决Centos/Redhat,命令不存在

    解决Centos/Redhat,命令不存在

    2022年2月23日
    59
  • 卸载烦人的赛门铁克

    卸载烦人的赛门铁克问题:电脑上SymantecEndpointProtection无法进行卸载,在卸载的时候提示需要密码。解决:网上查过很多的解决方法,比如修改相关注册表,或者使用360粉碎文件,但都没有将SymantecEndpointProtection卸载掉,最后查到需要使用CleanWipe来卸载。网上找了很多CleanWipe版本,但是卸载都是版本过低,导致卸载不了。本人使用的Cl…

    2022年4月29日
    93

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号