PHP artisan migrate 報錯顯示 could not find driver ,怎麼辦?

記錄下本身的錯誤php

1、mysql

一、緣由是沒有pdo擴展致使的,sql

二、解決辦法:打開php.ini,而後去掉如下兩行代碼以前的分號(;)便可。以下;shell

extension=php_pdo_firebird.dllui

extension=php_pdo_mysql.dllthis

2、spa

可是我運行pdo連接,仍是報這個錯。最後發現是本身的pdo連接字符串有問題,致使沒法鏈接。緣由是單引號與雙引號的做用沒有搞明白,單引號下的變量是php是不會去解析的,雙引號與沒有符號下的變量php纔會去解析。.net


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

vagrant

以上方法都不對的狀況下:3d

本地環境:

 

 

發如今本地使用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('所有完成');
    }


}
相關文章
相關標籤/搜索