I'm trying to use Zend Framework with SQL server 2005 express (through Pdo_Mssql with wamp installation) but seem that pdo can't connect to SQL. This is my code:
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);
ve hata sonucu her zaman:
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
Yani herkes ZF + SQL server ile bazı deneyime sahip, SQL server bazı özel yapılandırma gerekir? Istallation zaman ben sadece varsayılan istance kullanmak için belirtmek ettik ve karışık kimlik doğrulaması kullanmak için. Ayrıca Microsoft SQL Server Management Studio Express ile db ile başarılı bağlayabilirsiniz.