2009-03-11 9 views
0

Ich versuche, Zend Framework mit SQL Server 2005 Express (über Pdo_Mssql mit wamp Installation) zu verwenden, aber scheint, dass PDO keine Verbindung zu SQL herstellen kann. Dies ist mein Code:Zend Framework und SQL Server

require '../application/bootstrap.php'; 

try { 
    $db = Zend_Db::factory('Pdo_Mssql', array(
    'host'  => 'localhost', 
    'username' => 'sa', 
    'password' => 'verystrongpass', 
    'dbname' => 'msdb' 
)); 
    $db->getConnection(); 
} catch (Zend_Db_Adapter_Exception $e) { 
    $e->getMessage(); 
} catch (Zend_Exception $e) { 
    $e->getMessage(); 
} 


$sql = 'SELECT * FROM table'; 

$result = $db->fetchAll($sql); 

echo "----------------" . var_dump($result); 

und das Fehlerergebnis ist immer:

Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[01002] Unable to connect: SQL Server is unavailable or does not exist. (severity 9)' in C:\wamp\bin\php\php5.2.5\lib\Zend\Db\Adapter\Pdo\Abstract.php:130 Stack trace: #0 C:\wamp\bin\php\php5.2.5\lib\Zend\Db\Adapter\Pdo\Mssql.php(135): Zend_Db_Adapter_Pdo_Abstract->_connect()

1 C:\wamp\bin\php\php5.2.5\lib\Zend\Db\Adapter\Abstract.php(389):Zend_Db_Adapter_Pdo_Mssql->_connect()

2 C:\wamp\bin\php\php5.2.5\lib\Zend\Db\Adapter\Pdo\Abstract.php(205):Zend_Db_Adapter_Abstract->query('SELECT * FROM t...', Array)

3 C:\wamp\bin\php\php5.2.5\lib\Zend\Db\Adapter\Abstract.php(616): Zend_Db_Adapter_Pdo_Abstract->query('SELECT * FROM t...', Array)

4 C:\Documents and Settings\Luca\Documenti\Workspace\web\db\public\index.php(27): Zend_Db_Adapter_Abstract->fetchAll('SELECT * FROM t...') #5 {main} thrown in C:\wamp\bin\php\php5.2.5\lib\Zend\Db\Adapter\Pdo\Abstract.php on line 130

Wer also einige Erfahrung mit ZF + SQL Server, SQL Server eine spezielle Konfiguration benötigen? In der Installationszeit habe ich nur angegeben, dass ich die Standardeinstellungen verwenden und die gemischte Authentifizierung verwenden möchte. Außerdem kann ich erfolgreich mit db über Microsoft SQL Server Management Studio Express verbinden.

Antwort

1

Alle Installationen von SQL Server Express auf einer benannten Instanz von SQLEXPRESS anstelle einer Standardinstanz - siehe this.

So sollte Ihr Gastgeber aussehen

'host'  => 'localhost\SQLEXPRESS' 
+0

das gleiche Problem. –

0

Können Sie Sie php.ini pls überprüfen in, dass Sie die Pdo_Mssq.dll

aktiviert Wenn nicht entfernen die ";" vor dem Pdo_Mssql.dll

Dan

+1

Bitte keine Spam-Fußzeilen; Sie * werden * entfernt. –

0

denke ich Ihre

'host' => 'localhost\SQLEXPRESS' Konfiguration

sein sollte:

'host' => 'computer_name\SQLEXPRESS'