Connection via PHP to an SQL Server 2012 database

Asked

Viewed 424 times

1

My problem has some variants:

  • I have a website built on joomla, which is hosted on a linux server.
  • The administrator where I have hosted my website has already informed me that it will not install any php extension, so as not to get conflicts or problems on the server
  • The php module does not contain any connection extension to Sql server (e. g, sqlsrv, mssql)
  • I have a program in c#, and my database is stored on Amazon (SQL Server 2012)

To summarize, I need my site to be able to connect to my Sql Server 2012 database of my program to show on the website the information I have there, and can also add new information, change it etc.

If anyone knows how to make that same connection, taking into account the variables to which I am subject, I would appreciate it very much.

  • 1

    You can always have PHP also hosted on Amazon, and from there you connect to BD. Then it’s just link your PHP website with the Amazon.

  • 2

    I would change the server, where I’ve seen not install PHP extensions, this is deprivation of a service, change server urgently

  • Have you tried with adodb ?

  • Harry Potter but does the PHP there have the modules needed to connect to SQL Server? It’s just that if they don’t get back to the same situation I’m in now. Jorge B, could you explain your idea a little better? I didn’t quite understand how to do what you said.

  • Lost, thanks for the comment. What you suggested to me is necessary a correct adobd installation? It is that I am not able to install something, due to the restrictions that I have of the administrator of the accommodation.

  • 1

    @Hélder, so says the documentation just unzip the files in the project folder that already works. I don’t have sql server here to test. example

  • 3

    Is it possible to create a webservice? In this way, you, from your website, rescue the data from the Sqlserver database on the Amazon server by this service.

  • 1

    Do you have the opportunity to switch to a windows hosting at the same amount? If yes you can try the solution used at this link

  • @jefersondaniel the solution presented in this link only works in windows is?

  • @Leofilipe advises me to use SOAP? Do you know any webservice for such purpose that I intend already done?

  • @lost I will test the solution indicated by you. I will then give feedback if it works.

  • 1

    @lost doesn’t work but thanks anyway. In order to unzip, I noticed that to connect to bd sql server it uses the mssql extension, which is not included in PHP.

Show 7 more comments

1 answer

1

If on your host you are limited to extensions, I would resolve this using normal PHP to contain a service exposed on Amazon.

It would be a Webapi made on top of the SQL database, which PHP could then send HTTP calls to it and get the data in XML or JSON. So you can POST to set new records, PUT to make updates, DELETE to erase, and GET to select.

It is a very common methodology, called DAL (Data Access Layer, Data Layer) or API (Application Programming Interface).

  • but how do I connect with PHP to the SQL Server database? I cannot understand this part, due to the limitations I have.

  • My answer is that since you can’t make a direct connection, put a webservice on top. The web service will have all right and access to SQL Server, while PHP only calls the webservice. To call a webservice in PHP is quite simple, and for my understanding does not need extension.

  • I’ll try to do that and see if I can sort it out.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.