Wie kann ich die installieren pdo_sqlsrv auf meinem windows 2008 Server 2008 R2?

Ich versuche, mit PDO eine Verbindung zu einer SQL Server-Datenbank. Ich habe schon zu kämpfen mit ihm für eine Weile jetzt habe ich diesen Fatalen Fehler auf meiner Seite, wo ich versuche, eine Verbindung zu SQL Server

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: Diese Erweiterung erfordert die Microsoft SQL Server 2012 Native Client-ODBC-Treiber mit SQL Server kommunizieren. Rufen Sie die folgende URL für den download der Microsoft SQL Server 2012 Native Client-ODBC-Treiber für x86: http://go.microsoft.com/fwlink/?LinkId=163712'

Heruntergeladen habe ich die Laufwerke aus
http://www.microsoft.com/en-us/download/details.aspx?id=20098 (SQLSRV30.EXE)
Ich platziert haben Autofahrer in den ext-Verzeichnis, in dem php installiert ist auf dem Server 2008 R2-server.

Ich habe auch diese 2 Zeilen am Ende der Liste der Erweiterungen in der php.ini-Datei

extension=php_pdo_sqlsrv_53_nts.dll
extension=php_sqlsrv_53_nts.dll

Bin ich mit PH-PVersion 5.3.19
Server API CGI/FastCGI
Thread-Sicherheit deaktiviert

Sehe ich pdo_sqlsrv aber ich sehe nicht ein Client-API-Version.

Was muss ich sonst noch tun, um in der Lage sein zu verwenden PDO eine Verbindung zu dem remote-server, auf dem SQL databses? Muss ich irgendetwas installieren auf dem remote-Server?

dies ist ein screenshot von meinem php my admin-Bereich

Wie kann ich die installieren pdo_sqlsrv auf meinem windows 2008 Server 2008 R2?

Dies ist meine connection-Klasse

<?php

class connection {

    private $connString;
    private $userName;
    private $passCode;
    private $server;
    private $pdo;
    private $errorMessage;
    protected $lastQueryTime;
    protected $lastQuery;

    private $pdo_opt = array (
                            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
                            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
                            );




    function __construct($dbName = DATABASE_NAME, $serverName = DATABASE_HOST){

        //sets credentials
        $this->setConnectionCredentials($dbName, $serverName);

        //start the connect
        $this->startConnection();

    }

    function startConnection(){


            $this->pdo = new PDO($this->connString, $this->userName, $this->passCode, $this->pdo_opt);

            if( ! $this->pdo){

                $this->errorMessage  = 'Failed to connect to database. Please try to refresh this page in 1 minute. ';
                $this->errorMessage .= 'However, if you continue to see this message please contact your system administrator.';
                echo $this->getError();
            }
    }


    //this will close the PDO connection
    public function endConnection(){

        $this->pdo = null;
    }

    //return a dataset with the results
    public function getDataSet($query, $data = NULL)
    {
        $start = microtime(true);
        $cmd = $this->pdo->prepare( $query );

        $cmd->execute($data);
        $ret = $cmd->fetchAll();
        //$cmd->closeCursor();
        $this->lastQueryTime = microtime(true) - $start;
        $this->lastQuery = $query;

        return $ret;
    }



    public function processQuery($query, $data = NULL)
    {
        $start = microtime(true);
               //$this->pdo->beginTransaction();


        $cmd = $this->pdo->prepare( $query );
        $ret = $cmd->execute($data);
               //$this->pdo->commit();
               //$cmd->closeCursor();
        $this->lastQueryTime = microtime(true) - $start;
        $this->lastQuery = $query;

        return $ret;
    }


    //return last insert id
    public function lastInsertId($name = NULL) {
        if(!$this->pdo) {
            return false;
        }

        return $this->pdo->lastInsertId($name);
    }



    public function getOneResult($query, $data = NULL){
        $cmd = $this->pdo->prepare( $query );
        $cmd->execute($data);

        return $cmd->fetchColumn();
    }

    public function getError(){
        if($this->errorMessage != '')
            return $this->errorMessage;
        else
            return true;  //no errors found

    }

    //this where you need to set new server credentials with a new case statment
    function setConnectionCredentials($dbName, $serv){

        switch($serv){


            //MS SQL server
            case 'SQLSERVER':
                $this->connString   = 'sqlsrv:server='.$serv.';database='.$dbName;
                $this->userName     = 'username';  
                $this->passCode     = 'password';  
            break;

            //the defaults are predefined in the APP_configuration file - DO NOT CHANGE THE DEFAULT
            default:
                $this->connString   = 'mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=utf8';
                $this->userName     = DATABASE_USERNAME;
                $this->passCode     = DATABASE_PASSWORD;
            break;

            }

    }


public function lastQueryTime() {
    if(!$this->lastQueryTime) {
        throw new Exception('no query has been executed yet');
    }
    return $this->lastQueryTime;
}

public function lastQuery() {
    if(!$this->lastQuery) {
        throw new Exception('no query has been executed yet');
    }
    return $this->lastQuery;
}



}



?>

Dies ist, wie ich meine Klasse zu ziehen Sie ein dataset -

<?php
include('connection.php');

$sql_db = new connection('databaseName','SQLSERVER');

$call_details = $sql_db->getDataSet('SELECT
                                    LocalUserId AS loginName,
                                    RemoteNumberCallId AS PhoneNumber,
                                    SUM(CallDurationSeconds + HoldDurationSeconds + LineDurationSeconds) AS totalTalk
                                    FROM dbo.CallDetail WHERE LocalUserId = \'blah\' AND RemoteNumberCallId = \'123456789\'
                                    GROUP BY LocalUserId, RemoteNumberCallId');


$call_details->endConnection();

?>

Ich habe sogar versucht, diesen code so werde ich nicht mit meiner Klasse und ich habe immer noch die gleichen Fehler

 $ss = new PDO("sqlsrv:server=SQLSERVER; Database=databaseName", "userName", "Password");
  • Nichts. Sie sollten gut zu gehen.. Versuchen Sie es mit sqlsrv_query.
  • dass für dein Kommentar. was ist sqlsrv_query? und wie benutze ich das?
  • sqlsrv_query ist Teil der sqlsrv_ Reihe von PHP-Funktionen, die eine alternative zu PDO. Das wird dir nicht helfen, da dein problem liegt außerhalb von PHP, bei der Treiber - /OS-Ebene.
InformationsquelleAutor Mike | 2013-04-25
Schreibe einen Kommentar