Symfony的连接使用Windows Azure [英] Symfony connect with Windows Azure

查看:150
本文介绍了Symfony的连接使用Windows Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能听起来很疯狂,但我想用连接微软的Azure数据库连接symfony项目。

I know it may sounds crazy, but i want to connect a symfony project with microsoft azure database connection.

我寻觅了很多办法来解决问题,但我没有找到一个例子如何symfony项目以 Microsoft SQL Server的连接或与的Windows Azure

I have searched a lot to find the solution, but I did not find a single example how to connect a symfony project with a microsoft sql server or with windows azure.

做任何人都知道该怎么做,如果它是可能的?

Do anyone knows how to do that and if it is possible?

推荐答案

在创建任何服务始终有一个开放的记事本:

When you create any service always had a notepad open:

所以,当你创建的SQL Server您键入的用户和passowrd,然后创建SQL数据库,然后你选择一个SQL Server到新的数据库相关联。

So, when you created the SQL Server you type user and passowrd and then you create SQL Databases and then you choose a SQL Server to associate the new db.

使用这些东西创造你与PDO以这种方式连接:

With those things created you connect with PDO in this way:

try {   
    $conn = new PDO ( "sqlsrv:server = tcp:<SQL_SERVER>.database.windows.net,1433; Database = <SQL_DATABASE>", "<SQL_SERVER_USER>", "SQL_SERVER_USER_PASSWORD");
    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}catch ( PDOException $e ) {
print( "Error connecting to SQL Server." );
die(print_r($e));
}

其中,


  1. SQL_SERVER是在SQL Server
  2. 的名称
  3. SQL_DATABASE是关联到SQL_SERVER
  4. 的数据库的名称
  5. SQL_SERVER_USER&安培; SQL_SERVER_USER_PASSWORD都为SQL_SERVER
  6. 的用户名和密码
  1. SQL_SERVER is the name of the SQL Server
  2. SQL_DATABASE is the name of the database associated to the SQL_SERVER
  3. SQL_SERVER_USER & SQL_SERVER_USER_PASSWORD are the user and password for the SQL_SERVER

在交响乐您必须设置驾驶员PDO_SQLSRV,让学说做他的工作。

In Symphony you must set the driver to pdo_sqlsrv and let Doctrine do his work

获取连接字符串
你可以看到你的连接字符串要到门户网站,然后选择您DATABSE,然后点击查看数据库连接字符串,在新的面板,你会看到OBDC,PDFO​​ ...连接例如code 没有密码

更改用户密码
走在SQL服务器,然后单击顶部图标重置密​​码,修改它。

Change user password Go the the SQL server, then click in the top icon "reset password", change it.

这篇关于Symfony的连接使用Windows Azure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆