在php中找不到ODBC Driver Manager数据源名称

时间:2018-11-07 05:43:27

标签: php odbc

我雇了PHP开发人员来完成小任务,他进行了部署,向我展示了演示,然后它根本无法正常工作,并且开发人员现在也没有响应。

任务: 上传.mdb文件,将特定数据保存到phpmyadmin数据库中。

环境:本地虚拟机windows 2010 Server

应用程序:Senrifugo HRM(开放源代码)

错误: SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

在组织中,人们通过机器来打卡,并且机器可以导出.mdb文件以及所有数据。仅查找Person NameCheck-inCheck-out数据并保存到phpmyadmin数据库中。

代码

<?php
require_once 'public/constants.php';
require_once 'public/site_constants.php';
require_once 'public/email_constants.php';
require_once 'public/emptabconfigure.php';
require_once 'public/db_constants.php';
require_once 'public/application_constants.php';
require_once 'public/mail_settings_constants.php';
require_once 'application/modules/default/library/sapp/Global.php';
require_once 'public/text_constants.php';


// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/library'),
    get_include_path(),
)));



/** Zend_Application */
require_once 'Zend/Application.php';


// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();


$attendancesabsensemodel = new Default_Model_Attendancesabsense();

$dbName = MDB_DATABASE_PATH . "att2000.mdb";
if (!file_exists($dbName)) {
    die("HERE 1");
}

try {
    $dbName = MDB_DATABASE_PATH . "att2000.mdb";
    if (!file_exists($dbName)) {
        die("HERE 2");
    }
    $database_path = realpath($dbName);
    $database = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=$database_path; Uid=; Pwd=;");
  //  $date = new Datetime();
    $aujourdhui = gmdate("Y-m-d");
    $auj= gmdate("Y-m-d");
    /*** The SQL SELECT statement ***/

    $sql = "SELECT CHECKINOUT.USERID, CHECKINOUT.CHECKTIME, CHECKINOUT.CHECKTYPE, USERINFO.Badgenumber,USERINFO.Name
FROM CHECKINOUT INNER JOIN USERINFO ON CHECKINOUT.USERID = USERINFO.USERID
WHERE (((CHECKINOUT.CHECKTIME)>=#$aujourdhui#))";
    //  $sql = "SELECT * FROM CHECKINOUT WHERE  DATE('Y-m-d H:i:s','Checkintime') = DATE(NOW())";
  // die( $sql);
    /*** fetch into an PDOStatement object ***/
    $stmt = $database->query($sql);
    // print_r($stmt);
    $auth = Zend_Auth::getInstance();
    if($auth->hasIdentity()){
        $loginUserId = $auth->getStorage()->read()->id;
    }

    //this will fetch row by row and allows to change column name, format, etc:
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
       // die($row['USERID']);
        $json['USERID'] = $row['USERID'];
       // print_r($row);
        if($row['CHECKTYPE']=="I")
        {
            $json['CHECKTIME '] = $row['CHECKTIME'];
            $datetime1 = DateTime::createFromFormat('Y-m-d H:i:s', $auj.' 09:00:00');
            // A Hack using pages.dateformat.default: 'm-d-Y'`
            $datetime2 = DateTime::createFromFormat('Y-m-d H:i:s', $row['CHECKTIME']);
           // print_r($auj);
            $interval = $datetime1->diff($datetime2);
            $elapsed = $interval->format('%h hours %i minutes %s seconds');
            $json['CheckinTimeLate '] = $elapsed;

            $data = array(
                'attendancesabsense'  => $row['Name'],
                'badgenumb'  => $row['Badgenumber'],
                'attendancecheckin'  => $row['CHECKTIME'],
                'attendancecheckout'  =>    "",
                'absensestatut'  => $elapsed,
                'createdby'  => $loginUserId,
                'modifiedby'  => $loginUserId,
            );


            $data['createddate'] = gmdate("Y-m-d H:i:s");
            $data['modifieddate'] = gmdate("Y-m-d H:i:s");
            $data['isactive'] = 1;
            $where = '';

            $Id = $attendancesabsensemodel->SaveorUpdateAttendanceAbsenseData($data, $where);
        }
        else{
            $json['CHECKTIME '] = $row['CHECKTIME'];
            $datetime1 = DateTime::createFromFormat('Y-m-d H:i:s', $auj.' 17:00:00');
            // A Hack using pages.dateformat.default: 'm-d-Y'`
            $datetime2 = DateTime::createFromFormat('Y-m-d H:i:s', $row['CHECKTIME']);


            $interval = $datetime1->diff($datetime2);
            $elapsed = $interval->format('%h hours %i minutes %s seconds');
            $json['CheckOutTimeLate '] = $elapsed;

            $data = array(
                'attendancesabsense'  => $row['Name'],
                'badgenumb'  => $row['Badgenumber'],
                'attendancecheckin'  => "",
                'attendancecheckout'  =>    $row['CHECKTIME'],
                'absensestatut'  => $elapsed,
                'createdby'  => $loginUserId,
                'modifiedby'  => $loginUserId,
            );


            $data['createddate'] = gmdate("Y-m-d H:i:s");
            $data['modifieddate'] = gmdate("Y-m-d H:i:s");
            $data['isactive'] = 1;
            $where = '';

            $Id = $attendancesabsensemodel->SaveorUpdateAttendanceAbsenseData($data, $where);
        }



        $response[] = array('items' => $json);
      //  print_r($response);
    }



    /*** close the database connection ***/
    $database = null;

    header('Content-Type: application/json');
    echo "INSERTION CRON JOB DONE !";
    echo json_encode($response);
}
catch (PDOException $e)
{
    die($e->getMessage());
}

显示数据库数据的应用程序。

0 个答案:

没有答案