PHP Database connection without ODBC - php

I'm searching for a solution to connect to a Database (no matter the provider), with PHP.
BUT, I don't want to use the ODBC drivers.
I found that OLE DB is an alternative, but what are the possibilities if I want to use nix?

Related

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

Connecting to a Vertica DB with PHP

Is there a way to connect to a Vertica database with PHP -- a function similar to mysql_connect()?
I'm ultimately trying to write a script that pulls data from a Vertica database and stores it in a localhost MySQL database.
If necessary, I would be willing to work with Python to make this happen.
The PHP ODBC module (classic or PDO) works fine for Vertica connections. You'll need to download the appropriate ODBC driver for your Vertica version from the My Vertica portal and install it on your PHP server.
Also you can use a Postgres client libraries to connect to Vertica instance.

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'

Is there a way to connect MySQL to a SQL DB using PHP and not using mssql_pconnect()?

I want to connect a MySQL server (a gs server from mediaTemple) to a MySQL server using PHP, I cannot use the mssql_pconnect() function because they don't support it for their gs servers so I'm looking for an alternate route, I don't know if it's even possible.
What I want is to generate a connection on the MySQL server using PHP that will allow me to retrieve certain information from a View on a different server that's running SQL.
They probably don't support mssql_pconnect() because its for connecting to MSSQL and not MySQL, try using mysql_connect() or mysql_pconnect();
You should be able to establish 2 different database connections to 2 mysql servers simultaneously, as long as the host doesn't have some firewall rule that blocks the connection or some other safeguard like selinux.

Connection error accessing Sage Timberline Accounting with PHP and ODBC on Windows

I'm trying to connect to a Sage Timberline Accounting database on my Windows 2003 Server using PHP 5.3. I have PHP correctly installed with IIS as fastcgi. I have a system DSN setup in ODBC Manager and correctly configured for the Timberline database.
Here is my PHP script.
<?php
$conn = odbc_connect("Timberline ODBC","user", "password");
?>
I get the following error:
Warning: odbc_connect(): SQL error: [Sage Timberline Office][Sage Timberline Office ODBC Driver][DRM File Library]Invalid account name., SQL state 08001 in SQLConnect in C:\Inetpub\wwwroot\index.php on line 3
It doesn't matter what valid Timberline username and password combination I try.
Can anyone help?
Not sure if this is still a question or not...but you do realize that a pervasive SQL connection is to a index file that then has index references to the other information? Better known as a flat-file database structure.
As such, there is no clean cut way to make the connection. I am working on a similar problem with bridging my MSSQL server to the Timberline Database and it is not as clean cut as you would think.
Have you tried loading the Timberline Driver onto the webserver or into the application in question for consumption? Sage has not made it easy for you to access this information at all and if i have my 2 cents to say about this application suite, i would suggest against it at ALL cost.
So far here is a connection string that works, via VS2k5. It is a DSN string but connection string none the less. Problem i am having is dissoicating the DSN part from the connection string and getting it to work properly.
DSN=<whatever>;uid=<userid>;dbq=<PathToDirectory>;codepage=1252;
maxcolsupport=1536;dictionarymode=0;standardmode=0;shortennames=1;databasetype=1
This is supposed to work for ADO, but cant get it to work properly:
Provider=MSDASQL.1;Driver={Timberline Data};dbq=<PathToDirectory>;
uid=<userid>;pwd=<password>;codepage=1252
Make sure that IIS is running as a user that has access to the Timberline directory (the path you have set for the dbq parameter in your connection string).
Change the "Log On As" setting of your IIS service. Again, make sure you use an account that has access to the network location of your timberline data.
I'm using this code to build connection strings for use with ADO.NET to connect to Timberline. You can use it as a template for building a connection string in PHP. Also, consider using the default "Timberline Data Source" DSN.
public class TimberlineConnectionStringBuilder
{
public static string GetConnectionString(string username, string password, string dataFilePath, string dsn)
{
var builder = new OdbcConnectionStringBuilder { Dsn = dsn };
builder.Add("uid", username);
builder.Add("dbq", dataFilePath);
builder.Add("codepage", 1252);
builder.Add("dictionarymode", 0);
builder.Add("standardmode", 1);
builder.Add("maxcolsupport", 1536);
builder.Add("shortenames", 0);
builder.Add("databasetype", 1);
builder.Add("pwd", password);
return builder.ConnectionString;
}
}
I recently spent a lot of time making this work; I found a few dozen posts of folks that were not able to connect; but very few answers. These are my learnings:
Sage Timberline Office, now named Sage CRE 300, uses a Pervasive SQL Database. Their upgrade path is towards SQL Server by end of 2019.
There are 2 ODBC connections you can use to connect:
1. Use the native Pervasive ODBC drivers
The ODBC drivers are included in the free Pervasive Client. Just search for the latest install.
Both, 32 & 64 bit drivers are included.
PHP lets you connect through a simple connection string like: odbc_connect("Driver={Pervasive ODBC Interface};ServerName=myserver;ServerDSN=mydsn;", "", "", SQL_CUR_USE_ODBC);
Pervasive has lots of good up-to-date documentation available.
One giant downside: you can only read data. Sage fields are internally marked and need a password to allow updating. Sage will not provide the password; even for pay. (I tried).
2. Use the Sage provided ODBC driver
The only way to get the ODBC driver is by installing a Sage Client. (But read on, as you probably don't want to do this anyway).
The Sage ODBC driver is called Timberline Data, and a Simba product.
The driver is only available in 32 bit version.
The driver does more than interface:
- Pervasive table and field names are short; this ODBC driver acts like a translator providing long names. There are 2 versions of these long names. Decide what you want to use and stick to it.
- The Sage ODBC driver allows updating of fields. Not all fields; just the fields that Sage allows you to change. If updating is critical, then this is your only option.
This is the official connection string, and how you would use it in PHP:
odbc_connect("Driver={Timberline Data};UID=Mark;PWD=sage123!;DBQ=C:\Documents and Settings\All Users\Application Data\Sage\Timberline Office\Data\Construction Sample Data;CODEPAGE=1252;DictionaryMode=0;StandardMode=1;MaxColSupport=1536;", "", "", SQL_CUR_USE_ODBC);
I had no use for UID=Mark;PWD=sage123!;
Of course make sure to double all the backslashes. C:\\Documents and Settings\\All..
Sage states that their ODBC driver has only been tested with MS Office products; but it will also work with C++, C# etc. (Per Sage support.)
With the following exception: I was unable to use a UNC path in the connection string with C# or PHP. MS Access had no problem connecting using the UNC path. I could not make PHP work with the string. Mapped drives did not help; they might work for you.
Hints:
Make sure to use PHP 32 bit for the Sage ODBC driver; 64 bit will not
work!
For testing connecting with MS Access to the ODBC driver was easy; it served as a good way to get table and field names, and confirm the
connection string.
I ended up setting up a web server and installing a PHP instance on the Sage server. This has the following benefits:
No need to install a Sage Client (500MB) on your web server.
Provides 32 bit option if you are running your main site in 64 bit.
No issues with UNC paths
With this kind of error, you may need to ensure that only one windows profile has or been registered with the DSN name. In the other words If you have more profile registered with the same DSN name (in the same computer/server) this is most likely what cause the error!

Categories