How to make SQL server 2012 work with php? - php

How do I connect SQL server 2012 with php 5.6.3?
Like in mysql I use phpMyAdmin, how is it done in SQL server 2012?
Where do I have to save the database?

Nothing changes much while using different database service.
You can use Microsoft SQL Server Management Studio 2012 to create and manage your database.
Databases are automatically saved to SSMS's ( SQL Server Management Studio ) default location. But they can be easily transferred to different location by copying .mdf and .ldf files.
While using php ( or any other language ), make sure to keep running SQL Server Service and use proper connection String to connect to database.

Connecting to database
If you are on windows, use sqlsrv extension and do not forget install SQL Server Native Client 2012. sqlsrv supports also PDO - just use right connection string. On unix try to use mssql or odbc extension.
phpMyAdmin alternatives
SSMS (SQL Server Management Studio 2012) - tool that you can use but it is more for database administrators than developers.
SSDT (SQL Server Development Tool) - similar to SSMS but it is also capable to creating snapshots, comparing schemas, data-tier apps and much more. It is a part of Visual Studio or as standalone app.
Administration
SQL Server is a little bit more sofisticated database than MySQL. Database files are stored in Program Files by default (.mdf for database files, .ldf for transactions log). All administrator tasks, that you want to make as developer, could be done from SSMS (not from configuration file).

Related

Sync a MS SQL Database with a MySQL Database

I'm working on a CRM running on a MS Server working with a MSSQL Database and now I have designed a new platform for the CRM on a linux server with a MySQL database.
I've already used MySQL Workbench to migrate my MSSQL database to MySQL. However I would like to automatically sync them once per day.
Is there any tool or script (preferably on PHP) available for this kind of job. Otherwise can you give me an idea on how to do this?
Thanks in advance.
The process you want is called replication. Both SQL Server and MySQL support it. Here are links to the info you need to read:
MySQL Replication
SQL Server Replication

Sync Sage 100 Data from an ODBC Data Source to a MySQL Database

I am trying to setup remote access to the data of Sage 100 Advanced ERP for use within a website running on a MySQL database. I only need to get inventory levels for products, so it's a read-only application.
As I understand it, Sage 100 comes with an ODBC driver that can allow remote access to Sage's flat-file data storage by creating a database view. What I need to do is copy a few fields from that data on the Sage server over to the web server hosting the website.
To automate this process, I assume I'll need to setup a cron job on the web server that runs a PHP script (preferred language) executing SQL queries that connect to the remote server, extract the needed data, and write it to the appropriate tables in the MySQL database. I'm fine with that last step, but I'm unsure of the steps to connect and retrieve data from the ODBC data source.
How can I connect to and extract Sage 100 data from an ODBC Data Source to write to a MySQL Database on another server?
Or, is there a way to sync/mirror the ODBC Data Source to a MySQL Database on a separate server that I could then use to copy data over to the website's database?
Note: MySQL has documentation on pulling data FROM MySQL using ODBC, but no info on how to import data TO MySQL using ODBC on an external server.
It's actually very easy. Just establish an ODBC connection to the SOTAMAS90 DSN. Your connection string looks like this:
"DSN=SOTAMAS90; UID=MyUserId; PWD=MyPassword; Company=ABC"
Note that by default Sage installs a 32-bit version of the driver, which means you must target your application to 32 bits. Or you can install the 64-bit version of the driver, which can be found in your Sage directory, in the WKSetup folder.
After that just write code to SELECT * from each of the tables you need, and write them into your MySql database.
I don't really know MySql well, but in SQL Server you can set up a Linked Server, point it to SOTAMAS90, and then query the SQL Server database instead of the ODBC driver. But it's slow. Much better performance if you can run a nightly ETL to populate your MySQL database and query that. Be sure to set foreign keys and create indexes for them after to define the tables.
Hope that helps.
Aaron

is it necessary to use php to connect to the MySQL

is it necessary to use php to connect to the MySQL
i am working the desktop application and do not have a knowledge of php either
is there any in build class or functionality that can be use to connect to the MySQL
although there are many programme present over the internet to do so but unablefind one without the use of php. is there any reference or can i have the step by step example regarding the work.
MySQL config has the default settings. like username is root and password is blank my server name is local host.
No. PHP is a programming language. MySQL is a database. Install MySQL and type mysql from the command line and you will be connecting to MySQL using mysql.
MySQL docs
If you're writing a desktop application, mysql probably isn't the database you want to use. If you want to store data locally, try something like an embedded sqllite database. If you want to store the data remotely, I STRONGLY recommend to put the database behind an API. That is where something like PHP would come into play. It doesn't have to be PHP though. It can be python, java, ruby, etc.
Whatever you do though, DO NOT talk directly to a remote mysql database from your desktop app. That's just asking to have your db hacked.
MySQL has nothing to do with PHP, except that they are often bundled together. If you need to access MySQL by itself you can download MySql workbench.
http://www.mysql.com/products/workbench/
If you need a driver for your language google 'language + MySql Driver'

Accessing remote SQL Server database

I'm trying to access the mssql database of my website which a web design team has designed. They have given me the ip, port, db name, user and password... but how can I connect to the mssql server?
I have tried doing it via php but I think I have to compile php without "--without-mssql" "--without-pdo-mssql"... which I would not rather do on this windows 7 computer unless I have to.
I've tried SQL Server Management Studio Express but I couldn't find a way to access to a REMOTE database.
I've also tried Razor SQL but that did not connect either.
I almost tried something like phpmyadmin for asp.net but wanted to find an easier solution for this- without installing asp.net.
So what would be a good solution for managing a remote mssql database? Is there a program like Office Access that can handle such job?
SQL Server Management studio does support remote connections, in the small dialog you see in the middle of the screen when you run it, specify IP, username and password.
do you get any error? Which error do you get?
I am a fan of Navicat:
http://www.navicat.com/en/products/navicat_sqlserver/sqlserver_detail_win.html
However, I have not used the Sql Server version, but the MySQL and Oracle versions are pretty good - MySQL is awesome (mid range price point is the only draw back).
However Navicat Lite, which is still pretty good (and can handle most server types) is free!
Just a note, has the remote DB been setup for remote connections? If not you will not be able to get access no matter what you use.

Connecting to external MySQL DB from a web server not running MySQL

While I've been working with MySQL for years, this is the first time I've run across this very newbie-esq issue. Due to a client demand, I must host their website files (PHP) on a IIS server that is not running MySQL (instead, they are running MSSQL). However, I have developed the site using a MySQL database which is located on an external host (Rackspace Cloud). Obviously, my mysql_connect function is now bombing because MySQL is not running on localhost.
Question: Is it even possible to hit an external MySQL database if localhost is not running MySQL?
Apologies for the rookie question, and many thanks in advance.
* To clarify, I know how to connect to a remote MySQL server, but it is the fact that my IIS web server is not running ANY form of MySQL (neither server nor client) that is giving me trouble. Put another way, phpinfo() does not return anything about MySQL. *
Yes, you can use a MySQL database that's not on the same machine as Apache+PHP.
Basically, you'll connect from PHP to MySQL via a network connection -- TCP-based, I suppose ; which means :
MySQL must be configured to listen to, and accept connections on the network interface
Which means configuring MySQL to do that
And given the required privileges to your MySQL user, so he can connect from a remote server
And PHP must be able to connect to the server hosting MySQL.
Note, though, that habing MySQL on a server that's far away might not be great for performances : each SQL query will have to go through the network, and this could take some time...
If phpinfo is not returning anything about MySQL you need to install the MySQL plugin for PHP, easiest way to do that probably is to just upgrade PHP to the latest version. If not there is a .DLL file that you will need.
http://www.php.net/manual/en/mysql.installation.php
you will need to install the mysql extensions. this link should help: http://php.net/manual/en/install.windows.extensions.php
The MySQL server has nothing to do with PHP itself. What "mysql support" in PHP means is that it's been compiled with (or has a module loaded) that implements the MySQL client interface. For windows, it'd be 'mysql.dll', and on Unix-ish systems it'd be 'mysql.so'. Once those are loaded, then the various MySQL intefaces (mysql_xxx(), mysqli_xxx(), PDO, MDB2, etc...) will be able to access any MySQL server anywhere, as long as you have the proper connection string.

Categories