I've looked all over the web and cannot seem to find an answer for this one: I'm hoping to develop an app for my company using CakePHP 2. the problem is that the app will have to pull data from a Progress OpenEdge database. I've got the ODBC SQL driver for the database installed on the server but I cannot figure out how to add an ODBC datasource in CakePHP 2. Is this supported? If not (pretty stupid in my opinion, seeing as it was supported in 1.3), than what PHP framework would recommend that does support ODBC?
NOTE: While the ODBC driver can communicate SQL commands, you cannot communicate directly with the database using SQL, so it needs to be through the ODBC connection.
Related
Connecting to MSSQL using Doctrine2 on Unix
Im currently developing a project which uses Doctrine2 with PHP on an Ubuntu Server (x64). It's required to fetch data from a MSSQL-Server which is running externally.
Problem
Doctrine2 doesn't support the pdo_dblib driver, neither there's a support for sqlsrv on unix-like machines (sqlsrv is windows only). Being that given, it seems like Doctrine simply doesn't have a built-in support for MSSQL-Servers on unix-machines.
Solutions
These are solutions I tried without success.
1. Write own wrapper for pdo_dblib and integrate in doctrine's DBAL
I couldn't figure out how to write my own driver, platform and schema for doctrines DBAL neither found anything usefull in its docs or per google.
Actual Question
Is there any kind of support for MSSQL-Servers with Doctrine 2 without using Symfony or other third-party code ?
Your original solution is not actually that hard to achieve. I've run into this issue trying to connect to SQL Server using ODBC, which is one option for linux hosts, and the only change that I needed was in this file.
If you update that function and use a valid ODBC connection string instead, it will work just fine. Of course the Doctrine folks didn't make it easy by making that function private, so you'll either have to resort to editing your library or copy/pasting the entire SQL Server driver code.
That said, SQL Server support with ODBC is somewhat poor. For example, I've run into an issue where exceptions are thrown if you use bound parameters inside a subquery. Even though it works just fine with Microsoft's official driver which itself is based on ODBC. Go figure. If possible, copy your data to a more Linux friendly database and work with it there.
I’m actually developing a CI app in my developer machine with Windows and XAMPP, using de sqlsrv driver to connect to the MS SQL Server 2008 database.
But the final server machine is an Ubuntu server, and trying to run the app from there doesn’t work because of the sqlsrv driver not installed in the server.
I tried the mssql driver and the app starts to load but it ends with SQL queries errors (SQL queries previously tested and working).
What do you recommend?
Is it possible to connect from Linux/PHP/CI to SQL Server 2008? If there is a way, will it be as fast as running on Windows? It will be compatible with CI Active Record?
Is it better to create a new Windows server?
Thx
I would say that you should develop on whatever you deploy to so if you will stick to dev on windows, deploy to a windows box.
If you do want to get it working, I have seen a ruby app talk to ms sql 2005 before, you need to make sure you have FreeTds working, this looks like a good walkthrough:
http://php.net/manual/en/mssql.setup.php
If you are using sql 2008 there are some features which probably are not in sql 2008 like table valued parameters which FreeTds won't support so it might be not working because you are trying to use something it can't do - have a look at the query that fails and see what types it has and the types of the responses, if anything is new to sql 2008 it might not work.
I have been searching mssql driver for Laravel framework, but had no luck so far. I know Laravel has sqlsrv support for sql servers, but what I need is mssql connector (ones that have functions starting with 'mssql_').
We cannot use sqlsrv because most of our servers are MSSQL 2000, and sqlsrv doesn't provide support for these servers as far as I know. Also, MS does not provide sqlsrv driver for linux. (We are using freetds driver with manually compiled php 5.4.8 on Fedora 17 64-bit).
My question is
Is there any patch for mssql support in Laravel?
If not, which files should I create/modify to have mssql supported if it is ever possible?
I could use different framework that supports mssql as well, but I really like how Laravel handles everything. I didn't want to give up on Laravel just because it doesn't support mssql.
It seems it does not include that driver... I believe you can setup it at laravel/database/connectors
We have a CakePHP 1.3 application that we're in the process of upgrading to 2.2.3. One of the requirements of our app is to be able to query into an MSSQL database of a separate application to do some authentication and to pull user data out.
After two wasted days of researching and harassing our webhost to install the PHP / PDO / MSSQL lib (we already have PDO for MySQL, sqlite and sqlite 2) it's staring to seem pretty grim.
TL;DR: We need to find a way to do PDO MSSQL queries under Linux.
Begin Rant:
The thing that's driving me crazy is this: The CakePHP devs BROKE MSSQL compatibility for the sake of making all their DB wrappers with PDO. If you had a 1.3 app on a Linux server that was happily connecting to MSSQL databases and want to upgrade it to 2.2, you will no longer be able to connect to that database because apparently using PDO is more important than ensuring that you don't destroy existing functionality for your users.
CakePHP 2.x Docs do NOT warn users of this pitfall, all they say is that you need PDO.
There should be a notice that PDO/MSSQL does not work under Linux, or there should be an alterantive to the Sqlserver.php datasource that's provided with stock CakePHP so that people upgrading their apps have a chance of getting their applications functional again under 2.2x
I am really steamed about this right now because I wasted a week of time porting things over from 1.3 to 2.2 and now it looks like I either have to manually write the queries and ignore CakePHP's great database abstraction, or I need to convert all my work BACK to 1.3 and give up all the new improvements in the latest version of CakePHP.
The trick is :
sudo apt-get install php5-sybase
For some reason extension is not called mssql
sybase worked fine for me
What you need to do is install the ODBC drivers from Microsoft and set up the odbc connection strings. The process can be a bit tricky but it does work, and the driver is stable.
You can then use $dbh = new PDO("odbc:CONNECTIONNAME", $user, $password); to connect through PDO.
Once that is sorted, I think you can still use the MSSQL data source but modifying the connection string.
I have been looking around the current options (and related SO questions) regarding PHP ORM solutions, however I have a couple of unique requirements:
I am running PHP on Windows Server 2003
I need to interface with SQL Server 2005
I can't seem to find a simple answer from the PHP ORM solutions out there as to which (if any) support MSSQL as an adaptor option. Outlet seems to support this, for instance, but is only mentioned in passing on the documentation page, while other references say that the current version (1.0) has only been tested with MySQL.
At the moment, I am using the Microsoft PHP SQL Server driver, which as I understand it, can't be used with current ORM solutions until the driver itself supports PDO (which the team are looking into, but with no timeframe).
So what can I use today as an ORM solution on PHP for Windows that interfaces with SQL Server. Anything out there at all?
From Doctrine manual:
The currently supported PDO database drivers are:
fbsql FrontBase
ibase InterBase / Firebird (requires PHP 5)
mssql Microsoft SQL Server (NOT for Sybase. Compile PHP --with-mssql)
mysql MySQL
mysqli MySQL (supports new authentication protocol) (requires PHP 5)
oci Oracle 7/8/9/10
pgsql PostgreSQL
querysim QuerySim
sqlite SQLite 2
And PHP on Windows should ship with an appropriate extension for MSSQL for PDO. Just enable
extension=php_pdo.dll
extension=php_pdo_mssql.dll
Propel should also support MSSQL, as it is written on top of PDO. And while not a full fledged ORM as such, Zend_Db has an adapter for MSSQL as well. The latter uses pdo-dblib though.