"Error: could not find driver" triggers "Fatal error: Uncaught Error: Call to a member function prepare() on null"

"Error: could not find driver" triggers "Fatal error: Uncaught Error: Call to a member function prepare() on null"

基本上,当我尝试加载页面时,确切的错误消息如下:

Error: could not find driver
Fatal error: Uncaught Error: Call to a member function prepare() on null in /var/www/vhosts/FileA.php:46 Stack trace: #0 /var/www/vhosts/FileB.php(120): Database4->numofrows('select a.cardco...') #1 {main} thrown in /var/www/vhosts/FileA.php:46 on `line 46`

所以我转到有问题的 FileA.php 文件并按照他们上面所说的那样转到第 46 行。

FileA.php

<?php
    ini_set('max_execution_time',3600);
    Class Database4{
        protected $username;
        protected $password;
        protected $server;
        protected $dbName;
        public $conn;

        public function __construct(){
            $this->connection();
        }
        public function __destruct(){
            $this->conn=null;
        }
        protected function connection(){
            try{
                $this->username='dummyUser';
                $this->password='dummyPass';
                $this->server='192.168.0.42';
                $this->dbName='dummyDatabase';
                $this->conn=new PDO('dblib:host='.$this->server.':1433;dbname='.$this->dbName, $this->username, $this->password);

           } catch (PDOException $e){echo "Error: ".$e->getMessage();
       }
    }

            public function insert($sqlInsert)
    {
        $stmt=$this->conn->prepare($sqlInsert);
        $stmt->execute();
        return $stmt;
    }

    public function update($sqlUpdate){
        $stmt=$this->conn->prepare($sqlUpdate);
        $stmt->execute();
        return $stmt;
    }
    public function delete($sqlDelete){
        $stmt=$this->conn->prepare($sqlDelete);
        $stmt->execute();
        return $stmt;
    }
    public function select($sqlSelect){ 
        $stmt=$this->conn->prepare($sqlSelect);
        $stmt->execute();
        return $stmt;
    }
    public function numofrows($sql){
        $stmt=$this->conn->prepare($sql);
        $stmt->execute();
        $numofrows= count($stmt->fetchAll());
        return $numofrows;
    }
}
?>

查看代码后,似乎有大量答案说问题可能位于 FileA.phpline 22 上,我需要检查是否有 pdo_mysql已安装。

为了检查,我去看了看 /etc/php.ini 这是我设法在其中找到的内容。

extension=php_pdo_mysql.dll;
extension=php_pdo.dll;
extension=pdo.so;
extension=pdo_mysql.so;

郁闷了,去看一看FileB.php此时心情失落

<?php
    ini_set('max_execution_time',3600);
    ini_set('display_errors',1);
    ini_set('display_startup_errors',1);
    error_reporting(-1);

    include ("/FileA.php");
    include ("/irrelevant.php");
    $db4=New Database4;
    $db7=New Database7;

    $objPHPExcel = new PHPExcel();
    $objPHPExcel->getProperties()->setCreator("Creator")
                                ->setLastModifiedBy("Creator")
                                ->setTitle("Title")
                                ->setSubject("Subject")
                                ->setDescription("Description")
                                ->setKeywords("keywords")
                                ->setCategory("category");

    $cart_size=array(
    "2kg"=>array(
        "length"=>250,
        "width"=>200,
        "height"=>155,
        "weight"=>2    
    ),
    "5kg"=>array(
        "length"=>300,
        "width"=>200,
        "height"=>300,
        "weight"=>5
    ),
    "8kg"=>array(
        "length"=>400,
        "width"=>300,
        "height"=>250,
        "weight"=>8
    ),
    "15kg"=>array(
        "length"=>500,
        "width"=>400,
        "height"=>300,
        "weight"=>15
    ),
    "25kg"=>array(
        "length"=>500,
        "width"=>500,
        "height"=>400,
        "weight"=>25
    )

    );                       
    $csv_array=array();
    $csv_array[]="C_CONSIGNMENT_ID,C_POST_CHARGE_TO_ACCOUNT,C_CHARGE_CODE,C_MERCHANT_CONSIGNEE_CODE,C_CONSIGNEE_NAME,C_CONSIGNEE_BUSINESS_NAME,C_CONSIGNEE_ADDRESS_1,C_CONSIGNEE_ADDRESS_2,C_CONSIGNEE_ADDRESS_3,C_CONSIGNEE_ADDRESS_4,C_CONSIGNEE_SUBURB,C_CONSIGNEE_STATE_CODE,C_CONSIGNEE_POSTCODE,C_CONSIGNEE_COUNTRY_CODE,C_CONSIGNEE_PHONE_NUMBER,C_PHONE_PRINT_REQUIRED,C_CONSIGNEE_FAX_NUMBER,C_DELIVERY_INSTRUCTION,C_SIGNATURE_REQUIRED,C_PART_DELIVERY,C_COMMENTS,C_ADD_TO_ADDRESS_BOOK,C_CTC_AMOUNT,C_REF,C_REF_PRINT_REQUIRED,C_REF2,C_REF2_PRINT_REQUIRED,C_CHARGEBACK_ACCOUNT,C_RECURRING_CONSIGNMENT,C_RETURN_NAME,C_RETURN_ADDRESS_1,C_RETURN_ADDRESS_2,C_RETURN_ADDRESS_3,C_RETURN_ADDRESS_4,C_RETURN_SUBURB,C_RETURN_STATE_CODE,C_RETURN_POSTCODE,C_RETURN_COUNTRY_CODE,C_REDIR_COMPANY_NAME,C_REDIR_NAME,C_REDIR_ADDRESS_1,C_REDIR_ADDRESS_2,C_REDIR_ADDRESS_3,C_REDIR_ADDRESS_4,C_REDIR_SUBURB,C_REDIR_STATE_CODE,C_REDIR_POSTCODE,C_REDIR_COUNTRY_CODE,C_MANIFEST_ID,C_CONSIGNEE_EMAIL,C_EMAIL_NOTIFICATION,C_APCN,C_SURVEY,C_DELIVERY_SUBSCRIPTION,C_EMBARGO_DATE,C_SPECIFIED_DATE,C_DELIVER_DAY,C_DO_NOT_DELIVER_DAY,C_DELIVERY_WINDOW,C_CDP_LOCATION,C_IMPORTERREFNBR,C_SENDER_NAME,C_SENDER_CUSTOMS_REFERENCE,C_SENDER_BUSINESS_NAME,C_SENDER_ADDRESS_LINE1,C_SENDER_ADDRESS_LINE2,C_SENDER_ADDRESS_LINE3,C_SENDER_SUBURB_CITY,C_SENDER_STATE_CODE,C_SENDER_POSTCODE,C_SENDER_COUNTRY_CODE,C_SENDER_PHONE_NUMBER,C_SENDER_EMAIL,C_RTN_LABEL,A_ACTUAL_CUBIC_WEIGHT,A_LENGTH,A_WIDTH,A_HEIGHT,A_NUMBER_IDENTICAL_ARTS,A_CONSIGNMENT_ARTICLE_TYPE_DESCRIPTION,A_IS_DANGEROUS_GOODS,A_IS_TRANSIT_COVER_REQUIRED,A_TRANSIT_COVER_AMOUNT,A_CUSTOMS_DECLARED_VALUE,A_CLASSIFICATION_EXPLANATION,A_EXPORT_CLEARANCE_NUMBER,A_IS_RETURN_SURFACE,A_IS_RETURN_AIR,A_IS_ABANDON,A_IS_REDIRECT_SURFACE,A_IS_REDIRECT_AIR,A_PROD_CLASSIFICATION,A_IS_COMMERCIAL_VALUE,G_ORIGIN_COUNTRY_CODE,G_HS_TARIFF,G_DESCRIPTION,G_PRODUCT_TYPE,G_PRODUCT_CLASSIFICATION,G_QUANTITY,G_WEIGHT,G_UNIT_VALUE,G_TOTAL_VALUE";
    $line1=$csv_array[0];
    $csv_array[]="IGNORED,OPTIONAL,MANDATORY,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,OPTIONAL,OPTIONAL,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,IGNORED,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,MANDATORY,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,OPTIONAL,MANDATORY/OPTIONAL REFER TO GUIDE,OPTIONAL,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY,OPTIONAL,OPTIONAL,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE,MANDATORY/OPTIONAL REFER TO GUIDE";
    $line2=$csv_array[1];
    $xlsx="Online_Order_".date("Ymd").".xlsx";
    $xlsxPath=__DIR__."/online-order"."/$xlsx";
    $line1Array=array();
    $line1Array=explode(",",$line1);
    $line2Array=array();
    $line2Array=explode(",",$line2);
    $line3Array=array();
    $titleCounter=0;
    $letter='A';
    foreach ($line1Array as $line){
        $objPHPExcel->getActiveSheet()->setCellValue($letter."1",$line);

        $letter++;
        $titleCounter++;
    }
    $letter='A';
    foreach ($line2Array as $line){
        $objPHPExcel->getActiveSheet()->setCellValue($letter."2",$line);        
        $letter++;
    }

    $letter='A';
    for ($i=0;$i<$titleCounter;$i++){
    $objPHPExcel->getActiveSheet()->getColumnDimension($letter)->setAutoSize(true);
    $letter++;
    }

    $sqlGetSalesOrderHeader="select a.cardcode as cardcode, a.cardname as cardname, a.numatcard as numatcard, a.docnum as docnum, a.docdate as docdate,  c.CountyS as customer, c.StreetS as company, c.CityS as suburb, c.ZipCodeS as postcode, c.StateS as state, c.CountryS as country, a.U_UDF_Freight, CAST(a.U_UDF_IntCom AS TEXT) as U_UDF_IntCom, a.U_WC1_PHNE as U_WC1_PHNE, a.U_WC1_EMIL as U_WC1_EMIL, c.BlockS as address  
    from ordr a, rdr12 c
    where (a.cardcode='c00001' or a.cardcode='c00002') and  a.docentry=c.docentry and a.docstatus='o' and a.printed='Y'
    order by a.docdate asc";

    function outputCSV($csv_array, $full_path){
        $outputBuffer=fopen($full_path,"w");
        foreach($csv_array as $val){
            $line=explode(",",$val);
            fputcsv($outputBuffer,$line);
        }
        fclose($outputBuffer);
    }
    $total_order=$db4->numofrows($sqlGetSalesOrderHeader);
    if ($db4->numofrows($sqlGetSalesOrderHeader)>0){
        $resultGetSalesOrderHeader=$db4->select($sqlGetSalesOrderHeader);
        $rowsGetSalesOrderHeaders=$resultGetSalesOrderHeader->fetchAll();
        foreach ($rowsGetSalesOrderHeaders as $rowsGetSalesOrderHeader){
            $cardcode=$rowsGetSalesOrderHeader['cardcode'];
            $cardname=$rowsGetSalesOrderHeader['cardname'];
            $numatcard=$rowsGetSalesOrderHeader['numatcard'];
            $docnum=$rowsGetSalesOrderHeader['docnum'];
            $docdate=$rowsGetSalesOrderHeader['docdate'];
            $customer=str_replace(","," ",$rowsGetSalesOrderHeader['customer']);
            $address=str_replace(","," ",$rowsGetSalesOrderHeader['address']);
            $suburb=$rowsGetSalesOrderHeader['suburb'];
            $state=$rowsGetSalesOrderHeader['state'];
            $postcode=$rowsGetSalesOrderHeader['postcode'];
            $country=$rowsGetSalesOrderHeader['country'];
            $phone=$rowsGetSalesOrderHeader['U_WC1_PHNE'];
            $company=str_replace("=","",$rowsGetSalesOrderHeader['company']);
            $freight_instruction=str_replace(",", " ",$rowsGetSalesOrderHeader['U_UDF_Freight']);
            if (empty($freight_instruction)){
                $freight_instruction="Deliver during business hours.";
            }
            else{
                $freight_instruction="Deliver during business hours. ".$freight_instruction;
            }
            $cust_type=(stripos($rowsGetSalesOrderHeader['U_UDF_IntCom'],'business')!==false?"Business":"Residential");
            $email=$rowsGetSalesOrderHeader['U_WC1_EMIL'];
            if ($email==""){
                $notify="NONE";
            }else{
                $notify="DISPATCH";
            }
            $weight=0;
            $length=0;
            $width=0;
            $height=0;
            $tempLength=0;
            $tempHeight=0;
            $tempWidth=0;
            $sqlGetOrder="
        select d.itemcode as itemcode, d.quantity as quantity    
        from ordr a, rdr12 c, rdr1 d, oitm e
        where (a.cardcode='c00001' or a.cardcode='c00002')  and  a.docentry=c.docentry and a.docentry=d.docentry and a.docstatus='o' and e.itemcode=d.itemcode and a.numatcard='$numatcard' and a.printed='Y'
        ";
            $resultGetOrder=$db4->select($sqlGetOrder);
            while ($rowsGetOrder=$resultGetOrder->fetch(PDO::FETCH_BOTH)){
                $sItemcode=$rowsGetOrder['itemcode'];
                $sQuantity=$rowsGetOrder['quantity'];
                $sqlGetProducts="select weight, length, width, height from las_product_dimension where itemcode='$sItemcode'";
                $resultGetProducts=$db7->select($sqlGetProducts);
                while ($rowsGetProducts=mysqli_fetch_array($resultGetProducts)){
                    $dWeight=$rowsGetProducts[0];
                    $dLength=$rowsGetProducts[1];
                    $dWidth=$rowsGetProducts[2];
                    $dHeight=$rowsGetProducts[3];

                    if ($tempLength>$dLength){
                    $length=$tempLength;
                    }else{
                    $length=$dLength;
                    }
                    if ($tempWidth>$dWidth){
                        $width=$tempWidth;
                    }else{
                        $width=$dWidth;
                    }
                    $height+=$dHeight * $sQuantity;
                    $weight+=$dWeight * $sQuantity;
                    $tempWidth=$dWidth;
                    $tempLength=$dLength;   
                }
            }
            $csv_array[]=",,7D55,,$customer,$company,$address,,,,$suburb,$state,$postcode,$country,$phone,N,,$freight_instruction,Y,N,,Y,,$docnum,N,,N,,N,Laser Corporation Holdings Pty Ltd,Unit 1/6-8 Byfield St,,,,MACQUARIE PARK,NSW,2113,AU,,,,,,,,,,,,$email,$notify,,,,,,,,,,,,,,,,,,,,,,,N,$weight,$length,$width,$height,,,N,N,0,0,,,,,,,,,";
            $line3Array[]=",,7D55,,$customer,$company,$address,,,,$suburb,$state,$postcode,$country,$phone,N,,$freight_instruction,Y,N,,Y,,$docnum,N,,N,,N,Laser Corporation Holdings Pty Ltd,Unit 1/6-8 Byfield St,,,,MACQUARIE PARK,NSW,2113,AU,,,,,,,,,,,,$email,$notify,,,,,,,,,,,,,,,,,,,,,,,N,$weight,$length,$width,$height,,,N,N,0,0,,,,,,,,,";
        }
            $filename="exported_online_order_".date('Ymd').".csv";
            $full_path=__DIR__."/online-order/".$filename;
            outputCSV($csv_array, $full_path);
            $cust_array=array();
            $lineCount=3;
            foreach($line3Array as $line){
                $cust_array=explode(",",$line);
                $letter='A';

                foreach($cust_array as $cust_line){
                    if ($letter=='O'){
                        $objPHPExcel->getActiveSheet()->setCellValueExplicit($letter.$lineCount,$cust_line,PHPExcel_Cell_DataType::TYPE_STRING);
                    }
                    else{
                        $objPHPExcel->getActiveSheet()->setCellValue($letter.$lineCount,$cust_line);
                    }
                $letter++;
                }
                $lineCount++;
            }

            $objPHPExcel->getActiveSheet()->setTitle('Online Order');
            $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('U')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('W')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('Z')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('AB')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('AF')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('AG')->setVisible(false);
            $objPHPExcel->getActiveSheet()->getColumnDimension('AH')->setVisible(false);

            for ($col='AM'; $col!='BX'; $col++){
                if ($col!='AX' && $col!="AY" && $col!="BW" ){
                    $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setVisible(false);
                }
            }
            for ($col='CA'; $col!='CY'; $col++){
            $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setVisible(false);
            }

        $objPHPExcel->createSheet(NULL, 1);
        $objPHPExcel->setActiveSheetIndex(1);
        $objPHPExcel->getActiveSheet()->setTitle("Order");  
        $letter='A';
        $lineCount=1;
        $objPHPExcel->getActiveSheet()->setCellValue('A1','Document Number');
        $objPHPExcel->getActiveSheet()->setCellValue('B1','Order ID');
        $objPHPExcel->getActiveSheet()->setCellValue('C1','Product');
        $objPHPExcel->getActiveSheet()->setCellValue('D1','Quantity');
        $objPHPExcel->getActiveSheet()->setCellValue('E1','Customer Code');
        $objPHPExcel->getActiveSheet()->setCellValue('F1','Company Name');
        $objPHPExcel->getActiveSheet()->setCellValue('G1','Customer Name');
        $objPHPExcel->getActiveSheet()->setCellValue('H1','Address');
        $objPHPExcel->getActiveSheet()->setCellValue('I1','Suburb');
        $objPHPExcel->getActiveSheet()->setCellValue('J1','State');
        $objPHPExcel->getActiveSheet()->setCellValue('K1','Postcode');
        $objPHPExcel->getActiveSheet()->setCellValue('L1','Country');
        $objPHPExcel->getActiveSheet()->setCellValue('M1','Freight Instruction');
        $objPHPExcel->getActiveSheet()->setCellValue('N1','Customer Type');
        $lineCount=2;

        $sqlGetItem="
        select a.cardcode as cardcode, a.cardname as cardname, d.itemcode as itemcode, d.quantity as quantity, a.numatcard as numatcard, a.docnum as docnum, a.docdate as docdate,  c.CountyS as customer, c.BlockS as address, c.CityS as suburb, c.ZipCodeS as postcode, c.StateS as state, c.CountryS as country, a.U_UDF_Freight, CAST(a.U_UDF_IntCom AS TEXT) as U_UDF_IntCom 
        from ordr a, rdr12 c, rdr1 d
        where (a.cardcode='c00001' or a.cardcode='c00002') and  a.docentry=c.docentry and a.docentry=d.docentry and a.docstatus='o' and a.printed='Y'
        order by a.docdate asc
        ";

        $resultGetItem=$db4->select($sqlGetItem);
        while ($rowsGetItem=$resultGetItem->fetch(PDO::FETCH_BOTH)){
            $cardcode=$rowsGetItem['cardcode'];
            $cardname=$rowsGetItem['cardname'];
            $numatcard=$rowsGetItem['numatcard'];
            $docnum=$rowsGetItem['docnum'];
            $docdate=$rowsGetItem['docdate'];
            $customer=str_replace(","," ",$rowsGetItem['customer']);
            $customer=str_replace("=","",$customer);
            $address=str_replace(","," ",$rowsGetItem['address']);
            $suburb=$rowsGetItem['suburb'];
            $state=$rowsGetItem['state'];
            $postcode=$rowsGetItem['postcode'];
            $country=$rowsGetItem['country'];
            $itemcode=$rowsGetItem['itemcode'];
            $quantity=$rowsGetItem['quantity'];
            $freight_instruction=str_replace(",", " ",$rowsGetItem['U_UDF_Freight']);
            $cust_type=(stripos($rowsGetItem['U_UDF_IntCom'],'business')!==false?"Business":"Residential");

            $objPHPExcel->getActiveSheet()->setCellValue("A$lineCount", $docnum);
            $objPHPExcel->getActiveSheet()->setCellValue("B$lineCount", $numatcard);
            $objPHPExcel->getActiveSheet()->setCellValue("C$lineCount", $itemcode);
            $objPHPExcel->getActiveSheet()->setCellValue("D$lineCount", $quantity);
            $objPHPExcel->getActiveSheet()->setCellValue("E$lineCount", $cardcode);
            $objPHPExcel->getActiveSheet()->setCellValue("F$lineCount", $cardname);
            $objPHPExcel->getActiveSheet()->setCellValue("G$lineCount", $customer);
            $objPHPExcel->getActiveSheet()->setCellValue("H$lineCount", $address);
            $objPHPExcel->getActiveSheet()->setCellValue("I$lineCount", $suburb);
            $objPHPExcel->getActiveSheet()->setCellValue("J$lineCount", $state);
            $objPHPExcel->getActiveSheet()->setCellValue("K$lineCount", $postcode);
            $objPHPExcel->getActiveSheet()->setCellValue("L$lineCount", $country);
            $objPHPExcel->getActiveSheet()->setCellValue("M$lineCount", $freight_instruction);
            $objPHPExcel->getActiveSheet()->setCellValue("N$lineCount", $cust_type);
            $lineCount++;
        }
            for ($col = 'A'; $col != 'N'; $col++) {
            $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setAutoSize(true);
        }

        $objPHPExcel->createSheet(NULL, 2);
        $objPHPExcel->setActiveSheetIndex(2);
        $objPHPExcel->getActiveSheet()->setTitle("Pick List");  
        $letter='A';
        $lineCount=1;
        $objPHPExcel->getActiveSheet()->setCellValue('A1','Itemcode');
        $objPHPExcel->getActiveSheet()->setCellValue('B1','Pick QUantity');
        $objPHPExcel->getActiveSheet()->setCellValue('C1','Pick Warehouse');

        $lineCount=2;

        $sqlGetItem="
        select  d.itemcode as itemcode, sum(d.quantity) as quantity, (select top 1 ib.dfltWH From OITW ia, OITM ib where ia.ItemCode=d.ItemCode and ia.ItemCode=ib.ItemCode)  as defaultWH
        from ordr a, rdr12 c, rdr1 d
        where (a.cardcode='c00001' or a.cardcode='c00002') and  a.docentry=c.docentry and a.docentry=d.docentry and a.docstatus='o' and a.printed='Y'
        group by d.ItemCode

        ";
        $resultGetItem=$db4->select($sqlGetItem);
        $rowsGetItems=$resultGetItem->fetchAll();
        foreach ($rowsGetItems as $rowsGetItem)
        {
            $itemcode=$rowsGetItem['itemcode'];
            $qty=$rowsGetItem['quantity'];
            $defaultWH=($rowsGetItem['defaultWH']=="" || $rowsGetItem['defaultWH'] === NULL ? "Check somewhere" : $rowsGetItem['defaultWH'] );
            $sqlGetWarehouseBest="select (b.onHand - b.IsCommited - $qty) as available from OITM a, OITW b where a.ItemCode=b.ItemCode and a.ItemCode='$itemcode' and b.WhsCode='$defaultWH'";
            $resultGetWarehouseBest=$db4->select($sqlGetWarehouseBest);
            $available=0;

            $objPHPExcel->getActiveSheet()->setCellValue("A$lineCount", $itemcode);
            $objPHPExcel->getActiveSheet()->setCellValue("B$lineCount", $qty);
            $objPHPExcel->getActiveSheet()->setCellValue("C$lineCount", $defaultWH);

            $lineCount++;
        }
            for ($col = 'A'; $col != 'D'; $col++) {
            $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setAutoSize(true);
        }

        $objPHPExcel->setActiveSheetIndex(0);

        $callStartTime = microtime(true);
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save($xlsxPath);

            if (file_exists($full_path)):?>
            Download Online Order CSV file:  <a href="download_online_order.php?filename=<?php echo $full_path?>"><?php echo $filename;?></a> <br/>
            <?php else:?>
            No file Found

            <?php endif;?>
                <?php if (file_exists($xlsxPath)):?>
            Download Online Order Excel File:  <a href="download_online_order.php?filename=<?php echo $xlsxPath?>"><?php echo $xlsx;?></a> <br/>
            <?php endif;?>
        <?php
    }
    else{
        echo "No Sales Order Found";
    }
?>

我用 php -v 转换成美分 OS 我得到了:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/libr64/php/modules/php_pdo_mysql.dll' - /usr/lib64/php/modules/php_pdo_mysql.dll: cannot open shared object file: No such file or directory in line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/libr64/php/modules/php_pdo.dll' - /usr/lib64/php/modules/php_pdo.dll: cannot open shared object file: No such file or directory in line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/libr64/php/modules/php_mysql.so' - /usr/lib64/php/modules/php_mysql.so: cannot open shared object file: No such file or directory in line 0

PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP 7.0.18 (cli) (built: Apr 11 2017 14:25:57) (NTS)

我尝试了以下操作(没有成功——已安装消息):

yum install php-pdo
yum install php-pdo_mysql

在 运行 mysql -V 我得到:

mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Linux (x86_64) using readline 5.1

任何有建设性的东西都会很有帮助,因为这个持续存在的问题让我困惑了几个星期。此代码没有注释或文档,因为制作此代码的人已无法联系到。

请检查您的主机是否安装了 mssql ext,因为您正在尝试使用 FileA.php

连接到 mssql 服务器

对不起我的英语

我决定联系 OpenCart 支持以远程进入我的网络并让他们通过我们的文件系统和 Cent OS 终端进行操作。我不得不通过即时通讯工具共享我的屏幕,并让他们在我的监督下获得远程访问权限。

看起来他们知道要执行的正确扩展和正确的后续命令。

yum -y install mssql-server
cd /tmp/
mysql -u root -p website_com
mysql -u root -p website_com < oc.sql
mysql -u root -p website_com
shutdown -h +300