ODBC Support

Hello there,

first of all, thank you for developing and sharing this nice framework.

I started using it a couple of months ago, and it looks very solid and fast to be learned.

Anyway, I almost immediately noticed lack of ODBC support.

I need to access a MsSQL DB Server on Windows from my linux-hosted Yii app and, after googling for a while, I realized the only way to achieve this goal is using pdo/odbc. Unfortunately, odbc schema files are missing on official Yii release.

So, we (me and my colleague) started developing Yii odbc schema files based on mssql ones.

The main issues we had to round are related the the PHP/PDO #44643 bug (all parameters are binded as TEXT by the PDO driver): the dirty trick we used to solve this is casting parameters on SQL-Side (i.e. WHERE mycol = :par becomes WHERE mycol = CAST(:par AS VARCHAR) ).

The code actually is in “works for me” state. So, I’m wondering:

  1. Is the Yii community interested on having this patchwork included in the official Yii releases?

  2. If 1, is there anybody who can help test/develop it against different DBMS and make it "stable"? (Actually, only MsSQL is running)

I have a running PHP 5.2 /ODBC application on linx connecting to MsSQL.

Maybe I can test your work (but have not much time).

Why not AdoDB?

Mumble… how do you got it to work?

Anyway, I’m gonna made a patch file and attach it here.

AFAIK, AdoDB is not supported by PDO.

Sorry, forgot the link to AdoDb above.

Yesterday I had to take a look at the linux php server connected to MS-SQL-server.

The server is running since 4 years and I have forgotten the configuration.

I’m not using ODBC.

The configuration:

  • The php-lib AdoDB with the driver ‘ms-sql’ and the db-host ‘ms-sql-myinstance’-see below in freetds config.

    You can AdoDb integrate this in Yii, but have no Yii ActiveRecord.

    It will be a lot of work to migrate AdoDb ActiveRecords to Yii ActiveRecords.

  • freetds to connect from php to ms-sql

aptitude install freetds

edit /etc/freetds/freetds.conf and set the connection params


[ms-sql-myinstance]

host = 192.168.1.100

port = 1433

client charset = ISO-8859-1

tds version = 7.0


IMPORTANT: tds version must be set to 7.0, otherwise Params for storedproc

doesn’t work!!

Hello Gabriele,

I got exactly the same problem than you : access a MsSQL DB Server on Windows from my linux-hosted Yii app !

Have you released your Yii ODBC schema files ?

Hope it isn’t too late…

thx

We are encountering the same problem. I also wish to try and test the Yii patch for MsSQL Server. Gabriele could you give a link to the patch?

Hi, the patch applies to an old version of the framework.

We had it tested intensively for a couple of years now in prodution environment and it works without problems, but, because of lack of interest, I never managed to update it for lastest version of Yii.

You can find the patched source code (among with the full version history) here:

https github.com/gtozzi/yii/tree/gecoweb

There is a schema for MSSQL in Yii but it uses PDO drivers. Why do you need to reimplement the schema? If you want to use pdo_odbc for connection I’ve recently made a patch for Yii to support pdo_odbc. It is tagged for 1.1.15.