«Ошибка: не удалось найти драйвер» вызывает «Неустранимая ошибка: неперехваченная ошибка: вызов функции-члена prepare () on null» - PullRequest
0 голосов
/ 12 сентября 2018

Обычно, когда я пытаюсь загрузить страницу, точное сообщение об ошибке гласит:

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;
    }
}
?>

После просмотра кода появляется огромное количество ответов о том, что, возможно, проблема находится в line 22 из FileA.php, и мне потребуетсячтобы проверить, установлен ли я pdo_mysql.

Чтобы проверить, я пошел и посмотрел на /etc/php.ini, вот что мне удалось найти внутри него.

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

FeelingОшеломленный, я пошел посмотреть на файл 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 в Cent 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

Все конструктивное будет действительно полезным, так как эта постоянная проблема сохраняетсяменя озадачило уже несколько недель.Этот код не имеет комментариев или документации, так как человек, который сделал это, более недоступен.

Ответы [ 2 ]

0 голосов
/ 17 октября 2018

Я решил связаться со службой поддержки 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
0 голосов
/ 17 сентября 2018

Пожалуйста, проверьте ваш хост mssql ext установлен или нет, потому что вы пытаетесь подключиться к серверу mssql с помощью FileA.php

Извините за мой английский

...